@@ -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
876878class TestModule (unittest .TestCase ):
0 commit comments