push
travis-ci
896 of 1010 relevant lines covered (88.71%)
3.51 hits per line
1 |
# -*- coding: utf-8 -*-
|
|
2 |
|
|
3 |
# python stdlib
|
|
4 |
import sys |
4✔ |
5 |
|
|
6 |
|
|
7 |
if sys.version_info[0] < 3: |
4✔ |
8 |
# Python 2.x.x series
|
|
9 |
basestring = basestring # NOQA: F821 |
1 only 238.1 ✔ |
10 |
unicode = unicode # NOQA: F821 |
1 only 238.1 ✔ |
11 |
bytes = str # NOQA: F821 |
1 only 238.1 ✔ |
12 |
|
|
13 |
def u(x): |
1 only 238.1 ✔ |
14 |
return x.decode()
|
× |
15 |
|
|
16 |
def b(x): |
1 only 238.1 ✔ |
17 |
return x
|
× |
18 |
|
|
19 |
def nativestr(x): |
1 only 238.1 ✔ |
20 |
return x if isinstance(x, str) else x.encode('utf-8', 'replace') |
1 only 238.1 ✔ |
21 |
else:
|
|
22 |
# Python 3.x.x series
|
|
23 |
basestring = str # NOQA: F821 |
3 all except 238.1 ✔ |
24 |
unicode = str # NOQA: F821 |
3 all except 238.1 ✔ |
25 |
bytes = bytes # NOQA: F821 |
3 all except 238.1 ✔ |
26 |
|
|
27 |
def u(x): |
3 all except 238.1 ✔ |
28 |
return x
|
× |
29 |
|
|
30 |
def b(x): |
3 all except 238.1 ✔ |
31 |
return x.encode('latin-1') if not isinstance(x, bytes) else x |
× |
32 |
|
|
33 |
def nativestr(x): |
3 all except 238.1 ✔ |
34 |
return x if isinstance(x, str) else x.decode('utf-8', 'replace') |
3 all except 238.1 ✔ |