gh-118899: Add tests for NotImplemented attribute access (#118902)

This commit is contained in:
Nikita Sobolev 2024-05-12 17:00:49 +03:00 committed by GitHub
parent 5b941e57c7
commit ec1398e117
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -2138,6 +2138,24 @@ class BuiltinTest(unittest.TestCase):
with self.assertRaisesRegex(TypeError, msg):
not NotImplemented
def test_singleton_attribute_access(self):
for singleton in (NotImplemented, Ellipsis):
with self.subTest(singleton):
self.assertIs(type(singleton), singleton.__class__)
self.assertIs(type(singleton).__class__, type)
# Missing instance attributes:
with self.assertRaises(AttributeError):
singleton.prop = 1
with self.assertRaises(AttributeError):
singleton.prop
# Missing class attributes:
with self.assertRaises(TypeError):
type(singleton).prop = 1
with self.assertRaises(AttributeError):
type(singleton).prop
class TestBreakpoint(unittest.TestCase):
def setUp(self):