Deserializer: add Nullable fields

This commit is contained in:
Johannes Kirschbauer
2024-07-30 14:16:03 +02:00
parent e21bfbc257
commit 4b2d1b7923
2 changed files with 33 additions and 4 deletions

View File

@@ -83,6 +83,29 @@ def test_simple_field_missing() -> None:
from_dict(Person, person_dict)
def test_nullable() -> None:
@dataclass
class Person:
name: None
person_dict = {
"name": None,
}
from_dict(Person, person_dict)
def test_nullable_non_exist() -> None:
@dataclass
class Person:
name: None
person_dict = {}
with pytest.raises(ClanError):
from_dict(Person, person_dict)
def test_deserialize_extensive_inventory() -> None:
# TODO: Make this an abstract test, so it doesn't break the test if the inventory changes
data = {