diff --git a/tests/requests/invalid/version_03.http b/tests/requests/invalid/version_03.http new file mode 100644 index 000000000..a000b7b33 --- /dev/null +++ b/tests/requests/invalid/version_03.http @@ -0,0 +1,2 @@ +GET /foo HTTP/0.9\r\n +\r\n diff --git a/tests/requests/invalid/version_03.py b/tests/requests/invalid/version_03.py new file mode 100644 index 000000000..760840b69 --- /dev/null +++ b/tests/requests/invalid/version_03.py @@ -0,0 +1,2 @@ +from gunicorn.http.errors import InvalidHTTPVersion +request = InvalidHTTPVersion diff --git a/tests/test_invalid_requests.py b/tests/test_invalid_requests.py index a4748640f..71bfe9202 100644 --- a/tests/test_invalid_requests.py +++ b/tests/test_invalid_requests.py @@ -23,5 +23,6 @@ def test_http_parser(fname): cfg = env["cfg"] req = treq.badrequest(fname) - with pytest.raises(expect): + # telling pytest to match the exception string validates its __str__() + with pytest.raises(expect, match="."): req.check(cfg)