from unittest import TestCase
from uuid import UUID
+from hypothesis import given
+
from pyac import dumps
from pyac import loads
from pyac import NotEnoughData
+from tests.strategies import junk_st
class TestUUID(TestCase):
encoded: bytes = dumps(uuid_obj)
self.assertSequenceEqual(encoded, b"\x04\x124Vx\x124Vx\x124Vx\x124Vx")
- def test_uuid_decode(self) -> None:
+ @given(junk_st)
+ def test_uuid_decode(self, junk: bytes) -> None:
uuid_str: str = "12345678-1234-5678-1234-567812345678"
encoded: bytes = b"\x04\x124Vx\x124Vx\x124Vx\x124Vx"
decoded: UUID
- decoded, _ = loads(encoded)
+ decoded, tail = loads(encoded + junk)
self.assertEqual(decoded, UUID(uuid_str))
+ self.assertSequenceEqual(tail, junk)
def test_uuid_not_enough_data(self) -> None:
encoded: bytes = b"\x04\x124Vx\x124Vx\x124Vx\x124V"