Skip to content

Commit 76dc1bf

Browse files
[3.12] gh-118899: Add tests for NotImplemented attribute access (GH-118902) (#118969)
gh-118899: Add tests for `NotImplemented` attribute access (GH-118902) (cherry picked from commit ec1398e) Co-authored-by: Nikita Sobolev <[email protected]>
1 parent a0786bc commit 76dc1bf

File tree

1 file changed

+18
-0
lines changed

1 file changed

+18
-0
lines changed

Lib/test/test_builtin.py

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2091,6 +2091,24 @@ def test_warning_notimplemented(self):
20912091
with self.assertWarns(DeprecationWarning):
20922092
self.assertFalse(not NotImplemented)
20932093

2094+
def test_singleton_attribute_access(self):
2095+
for singleton in (NotImplemented, Ellipsis):
2096+
with self.subTest(singleton):
2097+
self.assertIs(type(singleton), singleton.__class__)
2098+
self.assertIs(type(singleton).__class__, type)
2099+
2100+
# Missing instance attributes:
2101+
with self.assertRaises(AttributeError):
2102+
singleton.prop = 1
2103+
with self.assertRaises(AttributeError):
2104+
singleton.prop
2105+
2106+
# Missing class attributes:
2107+
with self.assertRaises(TypeError):
2108+
type(singleton).prop = 1
2109+
with self.assertRaises(AttributeError):
2110+
type(singleton).prop
2111+
20942112

20952113
class TestBreakpoint(unittest.TestCase):
20962114
def setUp(self):

0 commit comments

Comments
 (0)