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 d54f644

Browse filesBrowse files
[3.11] gh-103193: Improve getattr_static test coverage (GH-104286) (#104290)
gh-103193: Improve `getattr_static` test coverage (GH-104286) (cherry picked from commit 921185e) Co-authored-by: Alex Waygood <Alex.Waygood@Gmail.com>
1 parent 499b79d commit d54f644
Copy full SHA for d54f644

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
@@ -2106,6 +2106,35 @@ class Thing(metaclass=Meta):
21062106
inspect.getattr_static(Thing, "spam")
21072107
self.assertFalse(Thing.executed)
21082108

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+
21092138
class TestGetGeneratorState(unittest.TestCase):
21102139

21112140
def setUp(self):

0 commit comments

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