Skip to content

Commit d26912a

Browse files
committed
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)
1 parent 26757d1 commit d26912a

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

Lib/test/test_httpservers.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1262,6 +1262,14 @@ def test_all(self):
12621262
expected.append(name)
12631263
self.assertCountEqual(server.__all__, expected)
12641264

1265+
def test_http_status_str_equals_value_str(self):
1266+
"""Ensure string render of an HTTPStatus is the same as of its
1267+
value attribute."""
1268+
for http_status_attr in HTTPStatus._member_map_:
1269+
http_status = getattr(HTTPStatus, http_status_attr)
1270+
with self.subTest(http_status_attr=http_status_attr):
1271+
self.assertEqual(str(http_status), str(http_status.value))
1272+
12651273

12661274
class ScriptTestCase(unittest.TestCase):
12671275

0 commit comments

Comments
 (0)