Skip to content

Commit 2f6b607

Browse files
sobolevnestyxx
authored andcommitted
pythongh-118899: Add tests for NotImplemented attribute access (python#118902)
1 parent 7652b6e commit 2f6b607

File tree

1 file changed

+18
-0
lines changed

1 file changed

+18
-0
lines changed

Lib/test/test_builtin.py

+18
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)