From be250ec5fde042d52311053163584786db43f69e Mon Sep 17 00:00:00 2001 From: paulefoe Date: Fri, 7 May 2021 05:36:27 +0300 Subject: [PATCH] Add regression test for HTTPUnathorized per #5657 --- CHANGES/5657.misc | 1 + tests/test_web_exceptions.py | 12 ++++++++++++ 2 files changed, 13 insertions(+) create mode 100644 CHANGES/5657.misc diff --git a/CHANGES/5657.misc b/CHANGES/5657.misc new file mode 100644 index 00000000000..d7d54e102eb --- /dev/null +++ b/CHANGES/5657.misc @@ -0,0 +1 @@ +Added regression test for ``HTTPUnauthorized`` body param diff --git a/tests/test_web_exceptions.py b/tests/test_web_exceptions.py index cf495db56ef..6c2bf63bd55 100644 --- a/tests/test_web_exceptions.py +++ b/tests/test_web_exceptions.py @@ -332,3 +332,15 @@ def test_pickle(self) -> None: assert resp2.reason == "Zaprescheno" assert resp2.status == 451 assert resp2.foo == "bar" + + +@pytest.mark.xfail( + raises=(TypeError, AttributeError), + reason="Regression in v3.7: https://github.com/aio-libs/aiohttp/issues/5657", +) +def test_body_unauthorized() -> None: + resp = web.HTTPUnauthorized( + headers={"X-Custom": "value"}, content_type="custom", body="text" + ) + assert resp.status == 401 + assert resp.text == "text"