@@ -995,101 +995,101 @@ class AClassWithMetaclass(metaclass=AMeta):
995995@cpython_only
996996class TestIncorrectNumberOfPositionalArgs (unittest .TestCase ):
997997 @contextlib .contextmanager
998- def assert_type_error_and_msg_equals (self , message : str ):
998+ def assert_type_error_and_msg_in (self , message : str ):
999999 with self .assertRaises (TypeError ) as cm :
10001000 yield
10011001 self .assertIn (message , str (cm .exception ))
10021002
10031003 def test_too_many_positional_with_defaults_suggests_missing_self (self ):
10041004 """A method with defaults that omits self should still get the hint."""
10051005 msg = ".method_two_args() takes from 0 to 2 positional arguments but 3 were given. Did you forget the 'self' parameter in the function definition?"
1006- with self .assert_type_error_and_msg_equals (msg ):
1006+ with self .assert_type_error_and_msg_in (msg ):
10071007 A ().method_two_args ("woof" , "loud" )
10081008
10091009 def test_too_many_positional_but_missing_self_no_args (self ):
10101010 """A zero-argument method called through an instance should get the hint."""
10111011 msg = "takes 0 positional arguments but 1 was given. Did you forget the 'self' parameter in the function definition?"
1012- with self .assert_type_error_and_msg_equals (msg ):
1012+ with self .assert_type_error_and_msg_in (msg ):
10131013 A ().method_zero_arg ()
10141014
10151015 def test_too_many_positional_but_missing_self (self ):
10161016 """A bound instance method missing self should get the targeted hint."""
10171017 msg = ".method_one_arg() takes 1 positional argument but 2 were given. Did you forget the 'self' parameter in the function definition?"
1018- with self .assert_type_error_and_msg_equals (msg ):
1018+ with self .assert_type_error_and_msg_in (msg ):
10191019 A ().method_one_arg ("quiet" )
10201020
10211021 def test_too_many_positional (self ):
10221022 msg = "takes 0 positional arguments but 1 was given"
1023- with self .assert_type_error_and_msg_equals (msg ):
1023+ with self .assert_type_error_and_msg_in (msg ):
10241024 A .static_no_args ("oops it's an arg" )
10251025
10261026 def test_positional_only_passed_as_keyword (self ):
10271027 msg = ".static_positional_only_one_arg() got some positional-only arguments passed as keyword arguments: 'arg1'"
1028- with self .assert_type_error_and_msg_equals (msg ):
1028+ with self .assert_type_error_and_msg_in (msg ):
10291029 A .static_positional_only_one_arg (arg1 = "ball" )
10301030
10311031 def test_unexpected_keyword (self ):
10321032 msg = "method_two_args() got an unexpected keyword argument 'bad'"
1033- with self .assert_type_error_and_msg_equals (msg ):
1033+ with self .assert_type_error_and_msg_in (msg ):
10341034 A ().method_two_args (bad = "x" )
10351035
10361036 def test_multiple_values (self ):
10371037 msg = ".method_two_args() got multiple values for argument 'arg1'"
1038- with self .assert_type_error_and_msg_equals (msg ):
1038+ with self .assert_type_error_and_msg_in (msg ):
10391039 A ().method_two_args ("quiet" , "low" , arg1 = "oops" )
10401040
10411041 def test_unbound_method_with_self_keeps_missing_argument_error (self ):
10421042 """Calling an unbound method without self should keep the missing-arg error."""
10431043 msg = ".method_one_arg() missing 1 required positional argument: 'arg1'"
1044- with self .assert_type_error_and_msg_equals (msg ):
1044+ with self .assert_type_error_and_msg_in (msg ):
10451045 A .method_one_arg ()
10461046
10471047 def test_classmethod_missing_cls_does_not_suggest_missing_self (self ):
10481048 """A classmethod missing cls conceptually should not suggest self."""
10491049 msg = ".classmethod_one_arg() takes 1 positional argument but 2 were given"
1050- with self .assert_type_error_and_msg_equals (msg ):
1050+ with self .assert_type_error_and_msg_in (msg ):
10511051 A .classmethod_one_arg ("poodle" )
10521052
10531053 def test_classmethod_missing_cls_via_instance_does_not_suggest_missing_self (self ):
10541054 """A classmethod called through an instance should not suggest self."""
10551055 msg = ".classmethod_one_arg() takes 1 positional argument but 2 were given"
1056- with self .assert_type_error_and_msg_equals (msg ):
1056+ with self .assert_type_error_and_msg_in (msg ):
10571057 A ().classmethod_one_arg ("poodle" )
10581058
10591059 def test_staticmethod_too_many_args_does_not_suggest_missing_self (self ):
10601060 """A staticmethod with too many arguments should not suggest self."""
10611061 msg = ".static_one_arg() takes 1 positional argument but 2 were given"
1062- with self .assert_type_error_and_msg_equals (msg ):
1062+ with self .assert_type_error_and_msg_in (msg ):
10631063 A .static_one_arg (1 , 2 )
10641064
10651065 def test_staticmethod_too_many_args_via_instance_does_not_suggest_missing_self (self ):
10661066 """A staticmethod called through an instance should not suggest self."""
10671067 msg = ".static_one_arg() takes 1 positional argument but 2 were given"
1068- with self .assert_type_error_and_msg_equals (msg ):
1068+ with self .assert_type_error_and_msg_in (msg ):
10691069 A ().static_one_arg (1 , 2 )
10701070
10711071 def test_metaclass_missing_receiver_does_not_suggest_missing_self (self ):
10721072 """A metaclass receiver error should not suggest an instance self."""
10731073 msg = "AMeta.method_one_arg() takes 1 positional argument but 2 were given"
1074- with self .assert_type_error_and_msg_equals (msg ):
1074+ with self .assert_type_error_and_msg_in (msg ):
10751075 AClassWithMetaclass .method_one_arg ("standard" )
10761076
10771077 def test_metaclass_method_too_many_args_does_not_suggest_missing_self (self ):
10781078 """A metaclass method with too many arguments should not suggest self."""
10791079 msg = "AMeta.method_two_arg() takes 2 positional arguments but 3 were given"
1080- with self .assert_type_error_and_msg_equals (msg ):
1080+ with self .assert_type_error_and_msg_in (msg ):
10811081 AClassWithMetaclass .method_two_arg ("trail" , "river" )
10821082
10831083 def test_metaclass_classmethod_does_not_suggest_missing_self (self ):
10841084 """A classmethod on a metaclass should not suggest instance self."""
10851085 msg = "AMeta.classmethod_one_arg() takes 1 positional argument but 2 were given"
1086- with self .assert_type_error_and_msg_equals (msg ):
1086+ with self .assert_type_error_and_msg_in (msg ):
10871087 AClassWithMetaclass .classmethod_one_arg ("standard" )
10881088
10891089 def test_metaclass_staticmethod_does_not_suggest_missing_self (self ):
10901090 """A staticmethod on a metaclass should not suggest instance self."""
10911091 msg = "AMeta.static_one_arg() takes 1 positional argument but 2 were given"
1092- with self .assert_type_error_and_msg_equals (msg ):
1092+ with self .assert_type_error_and_msg_in (msg ):
10931093 AClassWithMetaclass .static_one_arg ("show" , "working" )
10941094
10951095@cpython_only
0 commit comments