Serde: extend deserializer to accept anything

This commit is contained in:
Johannes Kirschbauer
2024-08-15 15:03:52 +02:00
parent 90b13dc803
commit cacd49ff54
3 changed files with 37 additions and 12 deletions

View File

@@ -157,6 +157,21 @@ def test_nullable_non_exist() -> None:
from_dict(Person, person_dict)
def test_list() -> None:
data = [
{"name": "John"},
{"name": "Sarah"},
]
@dataclass
class Name:
name: str
result = from_dict(list[Name], data)
assert result == [Name("John"), Name("Sarah")]
def test_deserialize_extensive_inventory() -> None:
# TODO: Make this an abstract test, so it doesn't break the test if the inventory changes
data = {