From 49d3e6a08ecf2498281204c47d150610cfd1fe26 Mon Sep 17 00:00:00 2001 From: sobolevn Date: Fri, 10 May 2024 16:35:42 +0300 Subject: [PATCH] gh-118899: Add tests for `NotImplemented` attribute access --- Lib/test/test_builtin.py | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/Lib/test/test_builtin.py b/Lib/test/test_builtin.py index a7631f92e7ea81..a7b35be936f8d9 100644 --- a/Lib/test/test_builtin.py +++ b/Lib/test/test_builtin.py @@ -2138,6 +2138,22 @@ def test_bool_notimplemented(self): with self.assertRaisesRegex(TypeError, msg): not NotImplemented + def test_not_implemented(self): + self.assertIs(type(NotImplemented), NotImplemented.__class__) + self.assertIs(type(NotImplemented).__class__, type) + + # Missing instance attributes: + with self.assertRaises(AttributeError): + NotImplemented.prop + with self.assertRaises(AttributeError): + NotImplemented.prop = 1 + + # Missing class attributes: + with self.assertRaises(AttributeError): + type(NotImplemented).prop + with self.assertRaises(TypeError): + type(NotImplemented).prop = 1 + class TestBreakpoint(unittest.TestCase): def setUp(self):