From 66551978835042949eea7d94450c2831e16984ee Mon Sep 17 00:00:00 2001 From: roman-annamoney Date: Tue, 12 Dec 2023 01:45:21 +0400 Subject: [PATCH] Default set to None --- tests/test_serialization.py | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/tests/test_serialization.py b/tests/test_serialization.py index d596797..c32e71a 100644 --- a/tests/test_serialization.py +++ b/tests/test_serialization.py @@ -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={},