File tree Expand file tree Collapse file tree 1 file changed +29
-0
lines changed Expand file tree Collapse file tree 1 file changed +29
-0
lines changed Original file line number Diff line number Diff line change @@ -2187,6 +2187,35 @@ class Thing(metaclass=Meta):
21872187 inspect .getattr_static (Thing , "spam" )
21882188 self .assertFalse (Thing .executed )
21892189
2190+ def test_custom___getattr__ (self ):
2191+ test = self
2192+ test .called = False
2193+
2194+ class Foo :
2195+ def __getattr__ (self , attr ):
2196+ test .called = True
2197+ return {}
2198+
2199+ with self .assertRaises (AttributeError ):
2200+ inspect .getattr_static (Foo (), 'whatever' )
2201+
2202+ self .assertFalse (test .called )
2203+
2204+ def test_custom___getattribute__ (self ):
2205+ test = self
2206+ test .called = False
2207+
2208+ class Foo :
2209+ def __getattribute__ (self , attr ):
2210+ test .called = True
2211+ return {}
2212+
2213+ with self .assertRaises (AttributeError ):
2214+ inspect .getattr_static (Foo (), 'really_could_be_anything' )
2215+
2216+ self .assertFalse (test .called )
2217+
2218+
21902219class TestGetGeneratorState (unittest .TestCase ):
21912220
21922221 def setUp (self ):
You can’t perform that action at this time.
0 commit comments