Skip to content

Commit 953c503

Browse files
committed
Mark all segments of Python 2-only code as *pragma: no cover*
This way such code is not considered by the coverage analyser, causing testing failures for Python 2 to not look like they decrease coverage and giving the actually relevant coverage figure when running `tox -e py3` rather than marking the Python 2 lines as untested in this case.
1 parent e9f6876 commit 953c503

File tree

6 files changed

+9
-9
lines changed

6 files changed

+9
-9
lines changed

multiaddr/codecs/_util.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
def packed_net_bytes_to_int(b):
33
"""Convert the given big-endian byte-string to an int."""
44
return int.from_bytes(b, byteorder='big')
5-
else: # PY2
5+
else: # pragma: no cover (PY2)
66
def packed_net_bytes_to_int(b):
77
"""Convert the given big-endian byte-string to an int."""
88
return int(b.encode('hex'), 16)

multiaddr/codecs/fspath.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,16 +13,16 @@
1313
if hasattr(os, "fsencode") and hasattr(os, "fsdecode"):
1414
fsencode = os.fsencode
1515
fsdecode = os.fsdecode
16-
else: # PY2
16+
else: # pragma: no cover (PY2)
1717
import sys
1818

1919
def fsencode(path):
20-
if not isinstance(path, six.binary_type): # pragma: no cover
20+
if not isinstance(path, six.binary_type):
2121
path = path.encode(sys.getfilesystemencoding())
2222
return path
2323

2424
def fsdecode(path):
25-
if not isinstance(path, six.text_type): # pragma: no cover
25+
if not isinstance(path, six.text_type):
2626
path = path.decode(sys.getfilesystemencoding())
2727
return path
2828

multiaddr/codecs/p2p.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212

1313
def to_bytes(proto, string):
1414
# the address is a base58-encoded string
15-
if six.PY2 and isinstance(string, unicode):
15+
if six.PY2 and isinstance(string, unicode): # pragma: no cover (PY2)
1616
string = string.encode("ascii")
1717
mm = base58.b58decode(string)
1818
if len(mm) < 5:

multiaddr/multiaddr.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ def __init__(self, addr):
3939
# On Python 2 text string will often be binary anyways so detect the
4040
# obvious case of a “binary-encoded” multiaddr starting with a slash
4141
# and decode it into text
42-
if six.PY2 and isinstance(addr, str) and addr.startswith("/"):
42+
if six.PY2 and isinstance(addr, str) and addr.startswith("/"): # pragma: no cover (PY2)
4343
addr = addr.decode("utf-8")
4444

4545
if isinstance(addr, six.text_type):
@@ -66,7 +66,7 @@ def __str__(self):
6666
# On Python 2 __str__ needs to return binary text, so expose the original
6767
# function as __unicode__ and transparently encode its returned text based
6868
# on the current locale
69-
if six.PY2:
69+
if six.PY2: # pragma: no cover (PY2)
7070
__unicode__ = __str__
7171

7272
def __str__(self):

multiaddr/protocols.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -123,7 +123,7 @@ def _uvarint(buf):
123123
for i, b_str in enumerate(buf):
124124
if six.PY3:
125125
b = b_str
126-
else:
126+
else: # pragma: no cover (PY2)
127127
b = int(binascii.b2a_hex(b_str), 16)
128128
if b < 0x80:
129129
if i > 9 or (i == 9 and b > 1):

multiaddr/transforms.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@ def string_iter(string):
7878
value = "/" + "/".join(sp)
7979
if not six.PY2:
8080
sp.clear()
81-
else:
81+
else: # pragma: no cover (PY2)
8282
sp = []
8383
else:
8484
value = sp.pop(0)

0 commit comments

Comments
 (0)