Skip to content

Commit 865d721

Browse files
authored
Add 'from_int()' function to test_adb_message.py (#87)
1 parent 292963d commit 865d721

1 file changed

Lines changed: 8 additions & 0 deletions

File tree

tests/test_adb_message.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,10 @@
88
from adb_shell.adb_message import AdbMessage, checksum, unpack
99

1010

11+
def from_int(n):
12+
return ''.join(chr((n >> (i * 8)) % 256) for i in range(4)).encode('utf-8')
13+
14+
1115
class TestAdbMessage(unittest.TestCase):
1216
def test_checksum_bytearray(self):
1317
cs = checksum(bytearray('TEST', 'utf-8'))
@@ -24,3 +28,7 @@ def test_checksum_unicode(self):
2428
def test_unpack_error(self):
2529
with self.assertRaises(ValueError):
2630
unpack(b'TEST')
31+
32+
def test_constants(self):
33+
for key, val in constants.ID_TO_WIRE.items():
34+
self.assertEqual(key, from_int(val))

0 commit comments

Comments
 (0)