From 6def8a4a489ce1321a44bc1947c5c86620afdb3f Mon Sep 17 00:00:00 2001 From: David Lord Date: Sat, 31 Oct 2020 20:17:04 -0700 Subject: [PATCH] test json.dumps for object with __html__ method --- tests/test_json.py | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/tests/test_json.py b/tests/test_json.py index 0d74d87e..73374fd1 100644 --- a/tests/test_json.py +++ b/tests/test_json.py @@ -6,6 +6,7 @@ import pytest from werkzeug.http import http_date import flask +from flask import json @pytest.mark.parametrize("debug", (True, False)) @@ -400,3 +401,12 @@ def test_json_key_sorting(app, client): assert lines == sorted_by_int except AssertionError: assert lines == sorted_by_str + + +def test_html_method(): + class ObjectWithHTML: + def __html__(self): + return "

test

" + + result = json.dumps(ObjectWithHTML()) + assert result == '"

test

"'