added hex methods

This commit is contained in:
2021-04-13 06:41:39 +00:00
parent 66aa7ee915
commit c63d2dd4bb
3 changed files with 39 additions and 0 deletions

View File

@@ -91,6 +91,18 @@ class TestBytes(TestCase):
with self.assertRaises(TypeError, msg="Bytes(\"1234\")"):
Bytes("1234")
def test_hex(self):
"""
Test conversion to hex string
"""
with self.subTest("Test hex() function"):
self.assertEqual(Bytes(1234).hex(), "04d2",
f"Bytes(1234).hex() == '04d2'")
self.assertEqual(Bytes(1234).hex(":"), "04:d2",
f"Bytes(1234).hex(':') == '04:d2'")
self.assertEqual(Bytes(1234).hex(":", 1), "04:d2",
f"Bytes(1234).hex(':', 1) == '04:d2'")
def test_comparison_operators(self):
"""
Test the comparison operators with Bytes objects