Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit 921185e

Browse filesBrowse files
authored
gh-103193: Improve getattr_static test coverage (#104286)
1 parent d513dde commit 921185e
Copy full SHA for 921185e

File tree

1 file changed

+29
-0
lines changed
Filter options

1 file changed

+29
-0
lines changed

‎Lib/test/test_inspect.py

Copy file name to clipboardExpand all lines: Lib/test/test_inspect.py
+29Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff 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+
21902219
class TestGetGeneratorState(unittest.TestCase):
21912220

21922221
def setUp(self):

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.