mirror of
https://github.com/python/cpython.git
synced 2025-08-31 05:58:33 +00:00
gh-118895: Call PyType_Ready() on typing.NoDefault (#118897)
This commit is contained in:
parent
c444362c6e
commit
13d7cf997b
4 changed files with 27 additions and 2 deletions
|
@ -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
|
||||
|
||||
|
||||
|
@ -10236,15 +10236,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__."""
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue