@@ -747,12 +747,15 @@ def __enter__(self):
747747 cm1 = CM1 ()
748748 meth = lookup (cm1 , "__enter__" )
749749 self .assertIsNotNone (meth )
750+ with self .assertRaisesRegex (
751+ TypeError , "missing 1 required positional argument" ) as cm :
752+ meth ()
750753 self .assertEqual (meth (cm1 ), "__enter__ from class __dict__" )
751754
752755 meth = lookup (cm1 , "__missing__" )
753756 self .assertIsNone (meth )
754757
755- with self .assertRaises (TypeError ):
758+ with self .assertRaisesRegex (TypeError , "attribute name must be string" ):
756759 lookup (cm1 , 123 )
757760
758761 cm2 = CM2 ()
@@ -768,6 +771,27 @@ def __enter__(self):
768771 self .assertIsNotNone (meth )
769772 self .assertEqual (meth ([]), 0 )
770773
774+ class Person :
775+ @classmethod
776+ def hi (cls ):
777+ return f"hi from { cls .__name__ } "
778+ @staticmethod
779+ def hello ():
780+ return "hello from static method"
781+ @property
782+ def name (self ):
783+ return "name from property"
784+ p = Person ()
785+ meth = lookup (p , "hi" )
786+ self .assertIsNotNone (meth )
787+ self .assertEqual (meth (), "hi from Person" )
788+
789+ meth = lookup (p , "hello" )
790+ self .assertIsNotNone (meth )
791+ self .assertEqual (meth (), "hello from static method" )
792+
793+ self .assertEqual (lookup (p , "name" ), "name from property" )
794+
771795 def test_lookup_special_method (self ):
772796 c_lookup = getattr (c_types , "lookup_special_method" )
773797 py_lookup = getattr (py_types , "lookup_special_method" )
0 commit comments