tests passing

This commit is contained in:
2020-10-21 05:34:06 +00:00
parent de72cfef04
commit 6e937879c2
3 changed files with 36 additions and 11 deletions

View File

@@ -10,7 +10,7 @@ class TestBytes(TestCase):
from math import ceil
test_ints = [0]
test_str = ["0"]
test_bytes = [b'0']
test_bytes = [b'']
test_bytearray = []
test_list_of_Bits = []
test_list_of_Bit = []
@@ -64,30 +64,43 @@ class TestBytes(TestCase):
"""
for title, tests in self.testcases.items():
with self.subTest(f"Create from {title}"):
# print("\tCreate Bytes from " + title)
for testcase in tests:
test = f"Bytes({testcase})"
test = "Bytes(testcase)"
compare = f"Bytes"
self.assertIsInstance(eval(test), eval(compare),
f"{test} is instance of {compare}")
#if not isinstance(testcase, int) and len(testcase) > 8:
# print(f"\t\t{testcase[0:9]}...")
#else:
# print(f"\t\t{testcase}")
try:
self.assertIsInstance(eval(test), eval(compare),
f"{test} is instance of {compare}")
except:
import pdb
pdb.set_trace()
with self.subTest(f"Create from bits.Bytes"):
#print("\tCreate from Bytes object")
for testcase in self.testcases["int"]:
test = f"Bytes(Bytes({testcase}))"
#print(f"\t\tBytes(Bytes({testcase}))")
test = "Bytes(Bytes(testcase))"
compare = f"Bytes"
self.assertIsInstance(eval(test), eval(compare),
f"{test} is instance of {compare}")
def test_errors(self):
with self.assertRaises(TypeError, "Bytes(\"1234\")"):
with self.assertRaises(TypeError, msg="Bytes(\"1234\")"):
Bytes("1234")
with self.assertRaises(ValueError, "Bytes(-1234)"):
Bytes(-1234)
def test_comparison_operators(self):
"""
Test the comparison operators with Bytes objects
"""
with self.subTest("Bytes Type"):
pass
for i in range(0, len(self.testcases["int"])):
self.assertEqual(Bytes(self.testcases["int"][i]),
Bytes(self.testcases["bytes"][i]),
(f"Bytes({self.testcases['int'][i]}) == "
f"Bytes({self.testcases['bytes'][i]})"))
with self.subTest("int Type"):
self.assertEqual(Bytes(1234), 1234,
"Bytes(1234) == 1234")
@@ -111,7 +124,7 @@ class TestBytes(TestCase):
"Bytes(512) >= 512")
self.assertLess(123, Bytes(125),
"123 < Bytes(125)")
self.assertlessEqual(1024, Bytes(2048),
self.assertLessEqual(1024, Bytes(2048),
"1024 <= Bytes(2048)")
self.assertLessEqual(4092, Bytes(4092),
"4092 <= Bytes(4092)")