@@ -169,6 +169,36 @@ def test_oldargs1_2_kw(self):
169169 msg = r"count\(\) takes no keyword arguments"
170170 self .assertRaisesRegex (TypeError , msg , [].count , x = 2 , y = 2 )
171171
172+ def test_argtype0 (self ):
173+ msg = r"^attribute name must be string, not 'int'$"
174+ self .assertRaisesRegex (TypeError , msg , getattr , 'foo' , 123 )
175+
176+ def test_argtype1 (self ):
177+ msg = r"^attribute name must be string, not 'int'$"
178+ self .assertRaisesRegex (TypeError , msg , hasattr , 'foo' , 123 )
179+
180+ def test_argtype2 (self ):
181+ msg = r"^attribute name must be string, not 'int'$"
182+ self .assertRaisesRegex (TypeError , msg , setattr , 'foo' , 123 , 'bar' )
183+
184+ def test_argtype3 (self ):
185+ msg = r"^attribute name must be string, not 'int'$"
186+ self .assertRaisesRegex (TypeError , msg , delattr , 'foo' , 123 )
187+
188+ def test_argtype4 (self ):
189+ msg = r"^attribute name must be string, not 'int'$"
190+ with self .assertRaisesRegex (TypeError , msg ):
191+ object .__getattribute__ ('foo' , 123 )
192+
193+ def test_argtype5 (self ):
194+ msg = r"^attribute name must be string, not 'int'$"
195+ with self .assertRaisesRegex (TypeError , msg ):
196+ object .__setattr__ ('foo' , 123 , 'bar' )
197+
198+ def test_argtype6 (self ):
199+ msg = r"^attribute name must be string, not 'int'$"
200+ with self .assertRaisesRegex (TypeError , msg ):
201+ object .__delattr__ ('foo' , 123 )
172202
173203
174204class TestCallingConventions (unittest .TestCase ):
0 commit comments