diff --git a/src/syrupy/extensions/json/__init__.py b/src/syrupy/extensions/json/__init__.py index 0b9a9540..d35a1efa 100644 --- a/src/syrupy/extensions/json/__init__.py +++ b/src/syrupy/extensions/json/__init__.py @@ -64,7 +64,7 @@ def _filter( elif matcher: data = matcher(data=data, path=path) - if isinstance(data, (int, float, str)): + if isinstance(data, (int, float, str)) or data is None: return data filtered_dct: Dict[Any, Any] diff --git a/tests/syrupy/extensions/json/__snapshots__/test_json_filters/test_exclude_in_json_with_empty_values.json b/tests/syrupy/extensions/json/__snapshots__/test_json_filters/test_exclude_in_json_with_empty_values.json index 2e8f3102..71d5f1ed 100644 --- a/tests/syrupy/extensions/json/__snapshots__/test_json_filters/test_exclude_in_json_with_empty_values.json +++ b/tests/syrupy/extensions/json/__snapshots__/test_json_filters/test_exclude_in_json_with_empty_values.json @@ -1,5 +1,5 @@ { "empty_dict": {}, "empty_list": [], - "none": "None" + "none": null } diff --git a/tests/syrupy/extensions/json/__snapshots__/test_json_filters/test_serializer[content2].json b/tests/syrupy/extensions/json/__snapshots__/test_json_filters/test_serializer[content2].json index f518b00f..990521bf 100644 --- a/tests/syrupy/extensions/json/__snapshots__/test_json_filters/test_serializer[content2].json +++ b/tests/syrupy/extensions/json/__snapshots__/test_json_filters/test_serializer[content2].json @@ -7,6 +7,6 @@ "datetime": "2021-01-31T23:59:00.000000", "float": 4.2, "int": -1, - "null": "None", + "null": null, "str": "foo" } diff --git a/tests/syrupy/extensions/json/__snapshots__/test_json_serializer/test_dict[actual2].json b/tests/syrupy/extensions/json/__snapshots__/test_json_serializer/test_dict[actual2].json index 658b2609..48e8cd1b 100644 --- a/tests/syrupy/extensions/json/__snapshots__/test_json_serializer/test_dict[actual2].json +++ b/tests/syrupy/extensions/json/__snapshots__/test_json_serializer/test_dict[actual2].json @@ -1,4 +1,5 @@ { "a": "Some ttext.", + "key": null, "multi\nline\nkey": "Some morre text." } diff --git a/tests/syrupy/extensions/json/__snapshots__/test_json_serializer/test_empty_snapshot.json b/tests/syrupy/extensions/json/__snapshots__/test_json_serializer/test_empty_snapshot.json index 68cab94d..19765bd5 100644 --- a/tests/syrupy/extensions/json/__snapshots__/test_json_serializer/test_empty_snapshot.json +++ b/tests/syrupy/extensions/json/__snapshots__/test_json_serializer/test_empty_snapshot.json @@ -1 +1 @@ -"None" +null diff --git a/tests/syrupy/extensions/json/test_json_serializer.py b/tests/syrupy/extensions/json/test_json_serializer.py index 7a6a2c11..9c1e359c 100644 --- a/tests/syrupy/extensions/json/test_json_serializer.py +++ b/tests/syrupy/extensions/json/test_json_serializer.py @@ -124,6 +124,7 @@ def test_set(snapshot_json, actual): "multi\nline\nkey": "Some morre text.", frozenset({"1", "2"}): ["1", 2], ExampleTuple(a=1, b=2, c=3, d=4): {"e": False}, + "key": None, }, {}, {"key": ["line1\nline2"]},