def test_lazy_strings_are_serialized(): serializer = JSONSerializer() lazy = {"key": _("Lazy")} list_lazy = [{"key": _("Lazy1")}, {"key": _("Lazy2")}] assert '{"key": "Lazy"}' == serializer.serialize_object(lazy) assert '[{"key": "Lazy1"}, {"key": "Lazy2"}]' == serializer.serialize_object_list( list_lazy)
def test_prettyprint(): app = Flask("test") with app.test_request_context("/?prettyprint=1"): serializer = JSONSerializer() assert '{\n "key": "1"\n}' == serializer.serialize_object( {"key": "1"})