Skip to content

Commit f5216ab

Browse files
hroncokfrenzymadness
authored andcommitted
Fix tests/parse_ifconfig.py on Python 3
1 parent 1aa27d5 commit f5216ab

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

tests/parse_ifconfig.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -186,11 +186,11 @@ def get_netmask_bits(self):
186186
# count bits in "packed":
187187
result = 0
188188
for ch in packed:
189-
ch = ord(ch)
189+
ch = ord(ch) if isinstance(ch, str) else ch
190190
while ch:
191191
if ch & 1:
192192
result += 1
193-
ch /= 2
193+
ch //= 2
194194
return result
195195

196196
def __repr__(self):
@@ -916,8 +916,8 @@ def test_parsing_device_line(self):
916916
self.assertEqual(dev.txcompressed, 11)
917917

918918
def test_parse_ip4addr(self):
919-
self.assertEqual(parse_ip4addr('1.1.1.1'), '\x01\x01\x01\x01')
920-
self.assertEqual(parse_ip4addr('127.0.0.1'), '\x7f\x00\x00\x01')
919+
self.assertEqual(parse_ip4addr('1.1.1.1'), b'\x01\x01\x01\x01')
920+
self.assertEqual(parse_ip4addr('127.0.0.1'), b'\x7f\x00\x00\x01')
921921

922922
def test_local(self):
923923
# Actually invoke ifconfig locally, and parse whatever it emits:

0 commit comments

Comments
 (0)