diff --git a/tests/test_requests.py b/tests/test_requests.py
index 2f83513c..f24fdcb5 100644
--- a/tests/test_requests.py
+++ b/tests/test_requests.py
@@ -11,7 +11,7 @@ import pytest
from sanic import Blueprint, Sanic
from sanic.exceptions import ServerError
from sanic.request import DEFAULT_HTTP_CONTENT_TYPE, RequestParameters
-from sanic.response import json, text
+from sanic.response import html, json, text
from sanic.testing import ASGI_HOST, HOST, PORT
@@ -72,6 +72,41 @@ def test_text(app):
assert response.text == "Hello"
+def test_html(app):
+ class Foo:
+ def __html__(self):
+ return "
Foo
"
+
+ def _repr_html_(self):
+ return "Foo object repr
"
+
+ class Bar:
+ def _repr_html_(self):
+ return "Bar object repr
"
+
+ @app.route("/")
+ async def handler(request):
+ return html("Hello
")
+
+ @app.route("/foo")
+ async def handler(request):
+ return html(Foo())
+
+ @app.route("/bar")
+ async def handler(request):
+ return html(Bar())
+
+ request, response = app.test_client.get("/")
+ assert response.content_type == "text/html; charset=utf-8"
+ assert response.text == "Hello
"
+
+ request, response = app.test_client.get("/foo")
+ assert response.text == "Foo
"
+
+ request, response = app.test_client.get("/bar")
+ assert response.text == "Bar object repr
"
+
+
@pytest.mark.asyncio
async def test_text_asgi(app):
@app.route("/")