summaryrefslogtreecommitdiffstats
path: root/Lib
diff options
context:
space:
mode:
authorMiss Islington (bot) <31488909+miss-islington@users.noreply.github.com>2024-05-10 16:36:33 (GMT)
committerGitHub <noreply@github.com>2024-05-10 16:36:33 (GMT)
commit6df49134b3f59a84c6d9a3883b23fa2873db2534 (patch)
treef054196ffc5fbd75dfcb538c90beb92260f81cd9 /Lib
parent0becae366c9d0b98d3f53849098e76bc8b1ef574 (diff)
downloadcpython-6df49134b3f59a84c6d9a3883b23fa2873db2534.zip
cpython-6df49134b3f59a84c6d9a3883b23fa2873db2534.tar.gz
cpython-6df49134b3f59a84c6d9a3883b23fa2873db2534.tar.bz2
[3.13] gh-118895: Call PyType_Ready() on typing.NoDefault (GH-118897) (#118914)
(cherry picked from commit 13d7cf997bc9c22cf67c42fd799413e8325e0039) Co-authored-by: Jelle Zijlstra <jelle.zijlstra@gmail.com>
Diffstat (limited to 'Lib')
-rw-r--r--Lib/test/test_typing.py23
1 files changed, 21 insertions, 2 deletions
diff --git a/Lib/test/test_typing.py b/Lib/test/test_typing.py
index fff81f7..f6fe953 100644
--- a/Lib/test/test_typing.py
+++ b/Lib/test/test_typing.py
@@ -45,7 +45,7 @@ import typing
import weakref
import types
-from test.support import captured_stderr, cpython_only, infinite_recursion
+from test.support import captured_stderr, cpython_only, infinite_recursion, requires_docstrings
from test.typinganndata import ann_module695, mod_generics_cache, _typed_dict_helper
@@ -10247,15 +10247,34 @@ class NoDefaultTests(BaseTestCase):
def test_constructor(self):
self.assertIs(NoDefault, type(NoDefault)())
with self.assertRaises(TypeError):
- NoDefault(1)
+ type(NoDefault)(1)
def test_repr(self):
self.assertEqual(repr(NoDefault), 'typing.NoDefault')
+ @requires_docstrings
+ def test_doc(self):
+ self.assertIsInstance(NoDefault.__doc__, str)
+
+ def test_class(self):
+ self.assertIs(NoDefault.__class__, type(NoDefault))
+
def test_no_call(self):
with self.assertRaises(TypeError):
NoDefault()
+ def test_no_attributes(self):
+ with self.assertRaises(AttributeError):
+ NoDefault.foo = 3
+ with self.assertRaises(AttributeError):
+ NoDefault.foo
+
+ # TypeError is consistent with the behavior of NoneType
+ with self.assertRaises(TypeError):
+ type(NoDefault).foo = 3
+ with self.assertRaises(AttributeError):
+ type(NoDefault).foo
+
class AllTests(BaseTestCase):
"""Tests for __all__."""