Update cherrypy-18.6.1

This commit is contained in:
JonnyWong16 2021-10-14 21:17:18 -07:00
parent b3ae6bd695
commit ebffd124f6
No known key found for this signature in database
GPG key ID: B1F1F9807184697A
57 changed files with 1269 additions and 1509 deletions

View file

@ -1,6 +1,6 @@
"""Test helpers from ``cherrypy.lib.httputil`` module."""
import pytest
from six.moves import http_client
import http.client
from cherrypy.lib import httputil
@ -49,12 +49,12 @@ EXPECTED_444 = (444, 'Non-existent reason', '')
(None, EXPECTED_200),
(200, EXPECTED_200),
('500', EXPECTED_500),
(http_client.NOT_FOUND, EXPECTED_404),
(http.client.NOT_FOUND, EXPECTED_404),
('444 Non-existent reason', EXPECTED_444),
]
)
def test_valid_status(status, expected_status):
"""Check valid int, string and http_client-constants
"""Check valid int, string and http.client-constants
statuses processing."""
assert httputil.valid_status(status) == expected_status
@ -62,19 +62,20 @@ def test_valid_status(status, expected_status):
@pytest.mark.parametrize(
'status_code,error_msg',
[
('hey', "Illegal response status from server ('hey' is non-numeric)."),
(
'hey',
r"Illegal response status from server \('hey' is non-numeric\)."
),
(
{'hey': 'hi'},
'Illegal response status from server '
"({'hey': 'hi'} is non-numeric).",
r'Illegal response status from server '
r"\(\{'hey': 'hi'\} is non-numeric\).",
),
(1, 'Illegal response status from server (1 is out of range).'),
(600, 'Illegal response status from server (600 is out of range).'),
(1, r'Illegal response status from server \(1 is out of range\).'),
(600, r'Illegal response status from server \(600 is out of range\).'),
]
)
def test_invalid_status(status_code, error_msg):
"""Check that invalid status cause certain errors."""
with pytest.raises(ValueError) as excinfo:
with pytest.raises(ValueError, match=error_msg):
httputil.valid_status(status_code)
assert error_msg in str(excinfo)