MCPcopy Index your code
hub / github.com/python/cpython / test_status_validation_errors

Method test_status_validation_errors

Lib/test/test_wsgiref.py:161–180  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

159 )
160
161 def test_status_validation_errors(self):
162 def create_bad_app(status):
163 def bad_app(environ, start_response):
164 start_response(status, [("Content-Type", "text/plain; charset=utf-8")])
165 return [b"Hello, world!"]
166 return bad_app
167
168 tests = [
169 ('200', 'AssertionError: Status must be at least 4 characters'),
170 ('20X OK', 'AssertionError: Status message must begin w/3-digit code'),
171 ('200OK', 'AssertionError: Status message must have a space after code'),
172 ]
173
174 for status, exc_message in tests:
175 with self.subTest(status=status):
176 out, err = run_amock(create_bad_app(status))
177 self.assertEndsWith(out,
178 b"A server error occurred. Please contact the administrator."
179 )
180 self.assertEqual(err.splitlines()[-2], exc_message)
181
182 def test_wsgi_input(self):
183 def bad_app(e,s):

Callers

nothing calls this directly

Calls 5

run_amockFunction · 0.85
assertEndsWithMethod · 0.80
subTestMethod · 0.45
assertEqualMethod · 0.45
splitlinesMethod · 0.45

Tested by

no test coverage detected