-import unittest
+from unittest import TestCase
from hypothesis import given
from hypothesis.strategies import binary
from pyac import NotEnoughData
-class TestBlob(unittest.TestCase):
+class TestBlob(TestCase):
def test_blob_encode(self) -> None:
blob = Blob(4, b"testdata")
encoded = dumps(blob)
-import unittest
+from unittest import TestCase
from hypothesis import given
from hypothesis.strategies import binary
from pyac import loads
-class TestBool(unittest.TestCase):
+class TestBool(TestCase):
def test_bool_encode_true(
self,
):
-import unittest
+from unittest import TestCase
from hypothesis import given
from hypothesis.strategies import integers
from pyac import NotEnoughData
-class TestError(unittest.TestCase):
+class TestError(TestCase):
@given(integers(min_value=1, max_value=100))
def test_not_enough_data_str(self, integer: int) -> None:
self.assertEqual(str(NotEnoughData(integer)), "{} bytes expected".format(integer))
-import unittest
+from unittest import TestCase
from typing import List
from pyac import Raw
-class TestFloat(unittest.TestCase):
+class TestFloat(TestCase):
def test_throws_when_dumps_float(self) -> None:
with self.assertRaises(NotImplementedError) as cm:
dumps(1.5)
-import unittest
+from unittest import TestCase
from pyac import dumps
from pyac import DecodeError
from pyac import NotEnoughData
-class TestInt(unittest.TestCase):
+class TestInt(TestCase):
def test_int_positive(self) -> None:
ints: list[int] = [1, 123, 1 << 64, 1 << 130]
expected: list[bytes] = [
-import unittest
+from unittest import TestCase
from hypothesis import given
from hypothesis.strategies import binary
)
-class TestList(unittest.TestCase):
+class TestList(TestCase):
def test_list_encode_empty(self) -> None:
encoded = dumps([])
self.assertEqual(encoded, b"\x08\x00")
-import unittest
+from unittest import TestCase
from hypothesis import given
from hypothesis.strategies import binary
)
-class TestMap(unittest.TestCase):
+class TestMap(TestCase):
@given(dictionaries(keys=mapkey_st, values=any_st, max_size=4))
def test_map_encode(self, test_map):
encoded = dumps(test_map)
-import unittest
+from unittest import TestCase
from hypothesis import given
from hypothesis.strategies import integers
)
-class TestString(unittest.TestCase):
+class TestString(TestCase):
@given(text(max_size=60))
def test_encode_utf8(self, test_str: str) -> None:
if(len(test_str.encode("utf-8")) > 60):
-import unittest
+from unittest import TestCase
from typing import Any
from hypothesis import given
)
-class TestSymmetric(unittest.TestCase):
+class TestSymmetric(TestCase):
@given(everything_st, binary(max_size=20))
def test_symmetric(self, obj: Any, junk: bytes) -> None:
encoded: bytes = dumps(obj) + junk
-import unittest
+from unittest import TestCase
from datetime import datetime
from datetime import timedelta
)
-class TestTAI64(unittest.TestCase):
+class TestTAI64(TestCase):
@given(binary(max_size=20))
def test_encode_decode_tai64(self, junk: bytes) -> None:
dt = datetime(2023, 10, 1, 12, 0, 0)
-import unittest
+from unittest import TestCase
from uuid import UUID
from pyac import NotEnoughData
-class TestUUID(unittest.TestCase):
+class TestUUID(TestCase):
def test_uuid_encode(self) -> None:
uuid_str: str = "12345678-1234-5678-1234-567812345678"
uuid_obj: UUID = UUID(uuid_str)