X-Git-Url: https://git.openstreetmap.org./nominatim.git/blobdiff_plain/4da4cbfe27a576ae011430b2de205c74435e241b..c70dfccacac90a90bfc193f49262abe7505d7d75:/test/python/utils/test_json_writer.py diff --git a/test/python/utils/test_json_writer.py b/test/python/utils/test_json_writer.py index 53e3f4d3..c0946f01 100644 --- a/test/python/utils/test_json_writer.py +++ b/test/python/utils/test_json_writer.py @@ -2,7 +2,7 @@ # # This file is part of Nominatim. (https://nominatim.org) # -# Copyright (C) 2024 by the Nominatim developer community. +# Copyright (C) 2025 by the Nominatim developer community. # For a full list of authors see the git log. """ Tests for the streaming JSON writer. @@ -13,6 +13,7 @@ import pytest from nominatim_api.utils.json_writer import JsonWriter + @pytest.mark.parametrize("inval,outstr", [(None, 'null'), (True, 'true'), (False, 'false'), (23, '23'), (0, '0'), (-1.3, '-1.3'), @@ -71,6 +72,7 @@ def test_object_single_entry(): assert writer() == '{"something":5}' json.loads(writer()) + def test_object_many_values(): writer = JsonWriter()\ .start_object()\ @@ -82,6 +84,7 @@ def test_object_many_values(): assert writer() == '{"foo":null,"bar":{},"baz":"b\\taz"}' json.loads(writer()) + def test_object_many_values_without_none(): writer = JsonWriter()\ .start_object()\ @@ -89,7 +92,7 @@ def test_object_many_values_without_none(): .keyval_not_none('bar', None)\ .keyval_not_none('baz', '')\ .keyval_not_none('eve', False, - transform = lambda v: 'yes' if v else 'no')\ + transform=lambda v: 'yes' if v else 'no')\ .end_object() assert writer() == '{"foo":0,"baz":"","eve":"no"}'