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 ec1398e

Browse filesBrowse files
authored
gh-118899: Add tests for NotImplemented attribute access (#118902)
1 parent 5b941e5 commit ec1398e
Copy full SHA for ec1398e

File tree

1 file changed

+18
-0
lines changed
Filter options

1 file changed

+18
-0
lines changed

‎Lib/test/test_builtin.py

Copy file name to clipboardExpand all lines: Lib/test/test_builtin.py
+18Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2138,6 +2138,24 @@ def test_bool_notimplemented(self):
21382138
with self.assertRaisesRegex(TypeError, msg):
21392139
not NotImplemented
21402140

2141+
def test_singleton_attribute_access(self):
2142+
for singleton in (NotImplemented, Ellipsis):
2143+
with self.subTest(singleton):
2144+
self.assertIs(type(singleton), singleton.__class__)
2145+
self.assertIs(type(singleton).__class__, type)
2146+
2147+
# Missing instance attributes:
2148+
with self.assertRaises(AttributeError):
2149+
singleton.prop = 1
2150+
with self.assertRaises(AttributeError):
2151+
singleton.prop
2152+
2153+
# Missing class attributes:
2154+
with self.assertRaises(TypeError):
2155+
type(singleton).prop = 1
2156+
with self.assertRaises(AttributeError):
2157+
type(singleton).prop
2158+
21412159

21422160
class TestBreakpoint(unittest.TestCase):
21432161
def setUp(self):

0 commit comments

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