@@ -458,7 +458,7 @@ def test_field_attr_writable(self):
458458 self .assertEqual (x ._fields , 666 )
459459
460460 def test_classattrs (self ):
461- msg = "Constant.__init__ missing 1 required positional argument: 'value'"
461+ msg = "ast. Constant.__init__ missing 1 required positional argument: 'value'"
462462 with self .assertRaisesRegex (TypeError , re .escape (msg )):
463463 x = ast .Constant ()
464464
@@ -485,11 +485,12 @@ def test_classattrs(self):
485485 self .assertRaises (TypeError , ast .Constant , 1 , None , 2 , lineno = 0 )
486486
487487 # Arbitrary keyword arguments are not supported
488- msg = "Constant.__init__ got an unexpected keyword argument 'foo'"
488+ msg = "ast. Constant.__init__ got an unexpected keyword argument 'foo'"
489489 with self .assertRaisesRegex (TypeError , re .escape (msg )):
490490 ast .Constant (1 , foo = 'bar' )
491491
492- with self .assertRaisesRegex (TypeError , "Constant got multiple values for argument 'value'" ):
492+ msg = "ast.Constant got multiple values for argument 'value'"
493+ with self .assertRaisesRegex (TypeError , re .escape (msg )):
493494 ast .Constant (1 , value = 2 )
494495
495496 self .assertEqual (ast .Constant (42 ).value , 42 )
@@ -529,7 +530,7 @@ def test_module(self):
529530
530531 def test_nodeclasses (self ):
531532 # Zero arguments constructor is not allowed
532- msg = "missing 3 required positional arguments: 'left', 'op', and 'right'"
533+ msg = "ast.BinOp.__init__ missing 3 required positional arguments: 'left', 'op', and 'right'"
533534 with self .assertRaisesRegex (TypeError , re .escape (msg )):
534535 x = ast .BinOp ()
535536
@@ -3211,8 +3212,8 @@ def test_FunctionDef(self):
32113212 args = ast .arguments ()
32123213 self .assertEqual (args .args , [])
32133214 self .assertEqual (args .posonlyargs , [])
3214- with self . assertRaisesRegex ( TypeError ,
3215- r"FunctionDef\.__init__ missing 1 required positional argument: 'name'" ):
3215+ msg = "ast.FunctionDef.__init__ missing 1 required positional argument: 'name'"
3216+ with self . assertRaisesRegex ( TypeError , re . escape ( msg ) ):
32163217 node = ast .FunctionDef (args = args )
32173218
32183219 node = ast .FunctionDef (name = 'foo' , args = args )
@@ -3232,8 +3233,8 @@ def test_expr_context(self):
32323233 self .assertEqual (name3 .id , "x" )
32333234 self .assertIsInstance (name3 .ctx , ast .Del )
32343235
3235- with self . assertRaisesRegex ( TypeError ,
3236- r"Name\.__init__ missing 1 required positional argument: 'id'" ):
3236+ msg = "ast.Name.__init__ missing 1 required positional argument: 'id'"
3237+ with self . assertRaisesRegex ( TypeError , re . escape ( msg ) ):
32373238 name3 = ast .Name ()
32383239
32393240 def test_custom_subclass_with_no_fields (self ):
0 commit comments