Skip to content

Commit 35e9a57

Browse files
committed
Fix failed tests in 3.11
1 parent 70dc6c6 commit 35e9a57

File tree

2 files changed

+5
-5
lines changed

2 files changed

+5
-5
lines changed

pycardano/serialization.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -568,15 +568,15 @@ class MapCBORSerializable(CBORSerializable):
568568
569569
Basic usage:
570570
571-
>>> from dataclasses import dataclass
571+
>>> from dataclasses import dataclass, field
572572
>>> @dataclass
573573
... class Test1(MapCBORSerializable):
574574
... a: str=""
575575
... b: str=""
576576
>>> @dataclass
577577
... class Test2(MapCBORSerializable):
578578
... c: str=None
579-
... test1: Test1=Test1()
579+
... test1: Test1=field(default_factory=Test1)
580580
>>> t = Test2(test1=Test1(a="a"))
581581
>>> t
582582
Test2(c=None, test1=Test1(a='a', b=''))
@@ -600,7 +600,7 @@ class MapCBORSerializable(CBORSerializable):
600600
>>> @dataclass
601601
... class Test2(MapCBORSerializable):
602602
... c: str=field(default=None, metadata={"key": "0", "optional": True})
603-
... test1: Test1=field(default=Test1(), metadata={"key": "1"})
603+
... test1: Test1=field(default_factory=Test1, metadata={"key": "1"})
604604
>>> t = Test2(test1=Test1(a="a"))
605605
>>> t
606606
Test2(c=None, test1=Test1(a='a', b=''))

test/pycardano/test_serialization.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,7 @@ class Test1(MapCBORSerializable):
8787
@dataclass
8888
class Test2(MapCBORSerializable):
8989
c: str = None
90-
test1: Test1 = Test1()
90+
test1: Test1 = field(default_factory=Test1)
9191

9292
t = Test2(test1=Test1(a="a"))
9393
assert t.to_cbor() == "a26163f6657465737431a261616161616260"
@@ -103,7 +103,7 @@ class Test1(MapCBORSerializable):
103103
@dataclass
104104
class Test2(MapCBORSerializable):
105105
c: str = field(default=None, metadata={"key": "0", "optional": True})
106-
test1: Test1 = field(default=Test1(), metadata={"key": "1"})
106+
test1: Test1 = field(default_factory=Test1, metadata={"key": "1"})
107107

108108
t = Test2(test1=Test1(a="a"))
109109
assert t.to_primitive() == {"1": {"0": "a", "1": ""}}

0 commit comments

Comments
 (0)