Skip to content

Commit d016dbe

Browse files
Update Lib/test/test_wsgiref.py
Co-authored-by: Victor Stinner <vstinner@python.org>
1 parent 563de46 commit d016dbe

File tree

1 file changed

+12
-10
lines changed

1 file changed

+12
-10
lines changed

Lib/test/test_wsgiref.py

Lines changed: 12 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -858,19 +858,21 @@ def write(self, b):
858858
def testRaisesControlCharacters(self):
859859
for c0 in control_characters_c0():
860860
with self.subTest(c0):
861-
base1, base2, base3 = [BaseHandler() for _ in range(3)]
862-
statusLegit = '200 OK'
863-
statusWithControlCharacters1 = c0
864-
headersLegit = [('x', 'y')]
865-
headersWithControlCharacters1 = [(c0, 'y')]
866-
headersWithControlCharacters2 = [('x', c0)]
867-
self.assertRaises(ValueError, base1.start_response, c0, headersLegit)
868-
self.assertRaises(ValueError, base2.start_response, statusLegit, headersWithControlCharacters1)
861+
base = BaseHandler()
862+
with self.assertRaises(ValueError):
863+
base.start_response(c0, [('x', 'y')])
864+
865+
base = BaseHandler()
866+
with self.assertRaises(ValueError):
867+
base.start_response('200 OK', [(c0, 'y')])
868+
869869
# HTAB (\x09) is allowed in header values, but not in names.
870+
base = BaseHandler()
870871
if c0 != "\t":
871-
self.assertRaises(ValueError, base3.start_response, statusLegit, headersWithControlCharacters2)
872+
with self.assertRaises(ValueError):
873+
base.start_response('200 OK', [('x', c0)])
872874
else:
873-
base3.start_response(statusLegit, headersWithControlCharacters2)
875+
base.start_response('200 OK', [('x', c0)])
874876

875877

876878
class TestModule(unittest.TestCase):

0 commit comments

Comments
 (0)