Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Test HTTPStatus items are stringified as values
It was discovered by @julianz- [[1]] that this works differently under
*NIX and on Windows. So this patch adds a test case to demonstrate the
inconsistency.

[1]: cherrypy/cheroot#800 (comment)
  • Loading branch information
webknjaz committed Dec 10, 2025
commit bd2d16d221fe1f51e1a88f8cf22853c907a065da
20 changes: 20 additions & 0 deletions Lib/test/test_httpservers.py
Original file line number Diff line number Diff line change
Expand Up @@ -1262,6 +1262,26 @@ def test_all(self):
expected.append(name)
self.assertCountEqual(server.__all__, expected)

def test_http_status_str_equals_value_str(self):
"""Ensure string render of an HTTPStatus is the same as of its
value attribute."""
for http_status_attr in HTTPStatus._member_map_:
http_status = getattr(HTTPStatus, http_status_attr)
with self.subTest(http_status_attr=http_status_attr):
self.assertEqual(str(http_status), str(http_status.value))

def test_http_status_str_is_numeric(self):
"""Ensure string render of an HTTPStatus is the same as of its
value attribute."""
for http_status_attr in HTTPStatus._member_map_:
http_status = getattr(HTTPStatus, http_status_attr)
with self.subTest(http_status_attr=http_status_attr):
self.assertTrue(str(http_status).isdigit())

def test_http_status_bad_request_str_looks_like_a_number(self):
"""Ensure string render of ``HTTPStatus.BAD_REQUEST`` is 400."""
self.assertEqual(str(HTTPStatus.BAD_REQUEST), '400')


class ScriptTestCase(unittest.TestCase):

Expand Down
Loading