Skip to content

Commit 6e855b3

Browse files
[3.13] gh-118899: Add tests for NotImplemented attribute access (GH-118902) (#118968)
gh-118899: Add tests for `NotImplemented` attribute access (GH-118902) (cherry picked from commit ec1398e) Co-authored-by: Nikita Sobolev <[email protected]>
1 parent d309474 commit 6e855b3

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
@@ -2139,6 +2139,24 @@ def test_warning_notimplemented(self):
21392139
with self.assertWarns(DeprecationWarning):
21402140
self.assertFalse(not NotImplemented)
21412141

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

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

0 commit comments

Comments
 (0)