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 @@ -2106,6 +2106,35 @@ class Thing(metaclass=Meta):
2106
2106
inspect .getattr_static (Thing , "spam" )
2107
2107
self .assertFalse (Thing .executed )
2108
2108
2109
+ def test_custom___getattr__ (self ):
2110
+ test = self
2111
+ test .called = False
2112
+
2113
+ class Foo :
2114
+ def __getattr__ (self , attr ):
2115
+ test .called = True
2116
+ return {}
2117
+
2118
+ with self .assertRaises (AttributeError ):
2119
+ inspect .getattr_static (Foo (), 'whatever' )
2120
+
2121
+ self .assertFalse (test .called )
2122
+
2123
+ def test_custom___getattribute__ (self ):
2124
+ test = self
2125
+ test .called = False
2126
+
2127
+ class Foo :
2128
+ def __getattribute__ (self , attr ):
2129
+ test .called = True
2130
+ return {}
2131
+
2132
+ with self .assertRaises (AttributeError ):
2133
+ inspect .getattr_static (Foo (), 'really_could_be_anything' )
2134
+
2135
+ self .assertFalse (test .called )
2136
+
2137
+
2109
2138
class TestGetGeneratorState (unittest .TestCase ):
2110
2139
2111
2140
def setUp (self ):
You can’t perform that action at this time.
0 commit comments