Skip to content

Commit

Permalink
Default set to None
Browse files Browse the repository at this point in the history
  • Loading branch information
roman-anna-money committed Dec 11, 2023
1 parent 5c3fcdb commit 6655197
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion tests/test_serialization.py
Original file line number Diff line number Diff line change
Expand Up @@ -156,14 +156,19 @@ class SimpleTypesContainers:
optional_enum_field="even",
)

raw_no_defaults = {k: v for k, v in raw.items() if not k.endswith("default") or not k.endswith("default_factory")}
raw_no_defaults = {k: v for k, v in raw.items() if not k.endswith("default") and not k.endswith("default_factory")}
raw_defaults_set_to_none = {
k: (v if not k.endswith("default") and not k.endswith("default_factory") else None) for k, v in raw.items()
}

loaded = mr.load(SimpleTypesContainers, raw)
loaded_no_defaults = mr.load(SimpleTypesContainers, raw_no_defaults)
loaded_defaults_set_to_none = mr.load(SimpleTypesContainers, raw_defaults_set_to_none)
dumped = mr.dump(loaded)

assert (
loaded_no_defaults
== loaded_defaults_set_to_none
== loaded
== SimpleTypesContainers(
any_field={},
Expand Down

0 comments on commit 6655197

Please sign in to comment.