mirror of
https://github.com/python/cpython.git
synced 2025-10-22 14:42:22 +00:00
gh-118899: Add tests for NotImplemented
attribute access (#118902)
This commit is contained in:
parent
5b941e57c7
commit
ec1398e117
1 changed files with 18 additions and 0 deletions
|
@ -2138,6 +2138,24 @@ class BuiltinTest(unittest.TestCase):
|
||||||
with self.assertRaisesRegex(TypeError, msg):
|
with self.assertRaisesRegex(TypeError, msg):
|
||||||
not NotImplemented
|
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):
|
class TestBreakpoint(unittest.TestCase):
|
||||||
def setUp(self):
|
def setUp(self):
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue