@@ -446,22 +446,22 @@ class PostInitTestClassDict(Streamable):
446
446
447
447
448
448
@streamable_enum (uint32 )
449
- class IntEnum (Enum ):
449
+ class IntegerEnum (Enum ):
450
450
A = 1
451
451
B = 2
452
452
453
453
454
454
@streamable_enum (str )
455
- class StrEnum (Enum ):
455
+ class StringEnum (Enum ):
456
456
A = "foo"
457
457
B = "bar"
458
458
459
459
460
460
@streamable
461
461
@dataclass (frozen = True )
462
462
class PostInitTestClassEnum (Streamable ):
463
- a : IntEnum
464
- b : StrEnum
463
+ a : IntegerEnum
464
+ b : StringEnum
465
465
466
466
467
467
@pytest .mark .parametrize (
@@ -474,7 +474,7 @@ class PostInitTestClassEnum(Streamable):
474
474
(PostInitTestClassTuple , ((1 , "test" ), ((200 , "test_2" ), b"\xba " * 32 ))),
475
475
(PostInitTestClassDict , ({1 : "bar" }, {bytes32 .zeros : {1 : "bar" }})),
476
476
(PostInitTestClassOptional , (12 , None , 13 , None )),
477
- (PostInitTestClassEnum , (IntEnum .A , StrEnum .B )),
477
+ (PostInitTestClassEnum , (IntegerEnum .A , StringEnum .B )),
478
478
],
479
479
)
480
480
def test_post_init_valid (test_class : type [Any ], args : tuple [Any , ...]) -> None :
@@ -541,8 +541,8 @@ class TestClass(Streamable):
541
541
f : Optional [uint32 ]
542
542
g : tuple [uint32 , str , bytes ]
543
543
h : dict [uint32 , str ]
544
- i : IntEnum
545
- j : StrEnum
544
+ i : IntegerEnum
545
+ j : StringEnum
546
546
547
547
# we want to test invalid here, hence the ignore.
548
548
a = TestClass (
@@ -554,8 +554,8 @@ class TestClass(Streamable):
554
554
None ,
555
555
(uint32 (383 ), "hello" , b"goodbye" ),
556
556
{uint32 (1 ): "foo" },
557
- IntEnum .A ,
558
- StrEnum .B ,
557
+ IntegerEnum .A ,
558
+ StringEnum .B ,
559
559
)
560
560
561
561
b : bytes = bytes (a )
@@ -667,19 +667,19 @@ class TestClassUint(Streamable):
667
667
a : uint32
668
668
669
669
# Does not have the required uint size
670
- with pytest .raises (ValueError ):
670
+ with pytest .raises (ValueError , match = re . escape ( "uint32.from_bytes() requires 4 bytes but got: 2" ) ):
671
671
TestClassUint .from_bytes (b"\x00 \x00 " )
672
672
673
673
674
674
def test_ambiguous_deserialization_int_enum () -> None :
675
675
@streamable
676
676
@dataclass (frozen = True )
677
- class TestClassIntEnum (Streamable ):
678
- a : IntEnum
677
+ class TestClassIntegerEnum (Streamable ):
678
+ a : IntegerEnum
679
679
680
- # Does not have the required uint size
681
- with pytest .raises (ValueError ):
682
- TestClassIntEnum .from_bytes (b"\x00 \x00 " )
680
+ # passed bytes are incorrect size for serialization proxy
681
+ with pytest .raises (ValueError , match = re . escape ( "uint32.from_bytes() requires 4 bytes but got: 2" ) ):
682
+ TestClassIntegerEnum .from_bytes (b"\x00 \x00 " )
683
683
684
684
685
685
def test_ambiguous_deserialization_list () -> None :
@@ -719,9 +719,9 @@ def test_ambiguous_deserialization_str_enum() -> None:
719
719
@streamable
720
720
@dataclass (frozen = True )
721
721
class TestClassStr (Streamable ):
722
- a : StrEnum
722
+ a : StringEnum
723
723
724
- # Does not have the required str size
724
+ # passed bytes are incorrect size for serialization proxy
725
725
with pytest .raises (AssertionError ):
726
726
TestClassStr .from_bytes (bytes ([0 , 0 , 100 , 24 , 52 ]))
727
727
0 commit comments