File tree 1 file changed +29
-0
lines changed
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):
2187
2187
inspect .getattr_static (Thing , "spam" )
2188
2188
self .assertFalse (Thing .executed )
2189
2189
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
+
2190
2219
class TestGetGeneratorState (unittest .TestCase ):
2191
2220
2192
2221
def setUp (self ):
You can’t perform that action at this time.
0 commit comments