From: Sergey Matveev Date: Sat, 30 Nov 2024 15:38:33 +0000 (+0300) Subject: Import only necessary single TestCase, not the whole module X-Git-Url: http://www.git.cypherpunks.su/?a=commitdiff_plain;h=90506005a83634720cea71ba91a3164baa5f51fcb20825eedb21312a4f34827e;p=keks.git Import only necessary single TestCase, not the whole module --- diff --git a/pyac/tests/test_blob.py b/pyac/tests/test_blob.py index ffef43a..152d3d7 100644 --- a/pyac/tests/test_blob.py +++ b/pyac/tests/test_blob.py @@ -1,4 +1,4 @@ -import unittest +from unittest import TestCase from hypothesis import given from hypothesis.strategies import binary @@ -10,7 +10,7 @@ from pyac import loads 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) diff --git a/pyac/tests/test_bool.py b/pyac/tests/test_bool.py index 586deb7..4e0766e 100644 --- a/pyac/tests/test_bool.py +++ b/pyac/tests/test_bool.py @@ -1,4 +1,4 @@ -import unittest +from unittest import TestCase from hypothesis import given from hypothesis.strategies import binary @@ -7,7 +7,7 @@ from pyac import dumps from pyac import loads -class TestBool(unittest.TestCase): +class TestBool(TestCase): def test_bool_encode_true( self, ): diff --git a/pyac/tests/test_errors.py b/pyac/tests/test_errors.py index b816910..7fa8801 100644 --- a/pyac/tests/test_errors.py +++ b/pyac/tests/test_errors.py @@ -1,4 +1,4 @@ -import unittest +from unittest import TestCase from hypothesis import given from hypothesis.strategies import integers @@ -10,7 +10,7 @@ from pyac import loads 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)) diff --git a/pyac/tests/test_float.py b/pyac/tests/test_float.py index cccf460..1dfc269 100644 --- a/pyac/tests/test_float.py +++ b/pyac/tests/test_float.py @@ -1,4 +1,4 @@ -import unittest +from unittest import TestCase from typing import List @@ -8,7 +8,7 @@ from pyac import NotEnoughData 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) diff --git a/pyac/tests/test_int.py b/pyac/tests/test_int.py index 768a6c8..ca5154c 100644 --- a/pyac/tests/test_int.py +++ b/pyac/tests/test_int.py @@ -1,4 +1,4 @@ -import unittest +from unittest import TestCase from pyac import dumps from pyac import DecodeError @@ -6,7 +6,7 @@ from pyac import loads 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] = [ diff --git a/pyac/tests/test_list.py b/pyac/tests/test_list.py index 6fffd04..55453e2 100644 --- a/pyac/tests/test_list.py +++ b/pyac/tests/test_list.py @@ -1,4 +1,4 @@ -import unittest +from unittest import TestCase from hypothesis import given from hypothesis.strategies import binary @@ -43,7 +43,7 @@ any_st = one_of( ) -class TestList(unittest.TestCase): +class TestList(TestCase): def test_list_encode_empty(self) -> None: encoded = dumps([]) self.assertEqual(encoded, b"\x08\x00") diff --git a/pyac/tests/test_map.py b/pyac/tests/test_map.py index afaac01..b8c4d54 100644 --- a/pyac/tests/test_map.py +++ b/pyac/tests/test_map.py @@ -1,4 +1,4 @@ -import unittest +from unittest import TestCase from hypothesis import given from hypothesis.strategies import binary @@ -46,7 +46,7 @@ mapkey_st = text( ) -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) diff --git a/pyac/tests/test_str.py b/pyac/tests/test_str.py index fd594be..5b0824f 100644 --- a/pyac/tests/test_str.py +++ b/pyac/tests/test_str.py @@ -1,4 +1,4 @@ -import unittest +from unittest import TestCase from hypothesis import given from hypothesis.strategies import integers @@ -25,7 +25,7 @@ invalid_utf8_3byte_s = integers(min_value=0, max_value=(1 << 10) - 1).map( ) -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): diff --git a/pyac/tests/test_symmetric.py b/pyac/tests/test_symmetric.py index 6cf674f..62db02d 100644 --- a/pyac/tests/test_symmetric.py +++ b/pyac/tests/test_symmetric.py @@ -1,4 +1,4 @@ -import unittest +from unittest import TestCase from typing import Any from hypothesis import given @@ -57,7 +57,7 @@ everything_st = deferred( ) -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 diff --git a/pyac/tests/test_tai.py b/pyac/tests/test_tai.py index 9fd24f4..6af631d 100644 --- a/pyac/tests/test_tai.py +++ b/pyac/tests/test_tai.py @@ -1,4 +1,4 @@ -import unittest +from unittest import TestCase from datetime import datetime from datetime import timedelta @@ -49,7 +49,7 @@ DJB_Leapsecs = ( ) -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) diff --git a/pyac/tests/test_uuid.py b/pyac/tests/test_uuid.py index 806f664..4fe2eb6 100644 --- a/pyac/tests/test_uuid.py +++ b/pyac/tests/test_uuid.py @@ -1,4 +1,4 @@ -import unittest +from unittest import TestCase from uuid import UUID @@ -7,7 +7,7 @@ from pyac import loads 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)