Currently NoDefaultTests cover many major use-cases:
|
class NoDefaultTests(BaseTestCase): |
|
def test_pickling(self): |
|
for proto in range(pickle.HIGHEST_PROTOCOL + 1): |
|
s = pickle.dumps(NoDefault, proto) |
|
loaded = pickle.loads(s) |
|
self.assertIs(NoDefault, loaded) |
|
|
|
def test_constructor(self): |
|
self.assertIs(NoDefault, type(NoDefault)()) |
|
with self.assertRaises(TypeError): |
|
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 |
However, they never test that NoDefault type is final, since it does not have Py_TPFLAGS_BASETYPE flag set.
I will send a PR.
Linked PRs
Currently
NoDefaultTestscover many major use-cases:cpython/Lib/test/test_typing.py
Lines 11096 to 11132 in 426f99c
However, they never test that
NoDefaulttype is final, since it does not havePy_TPFLAGS_BASETYPEflag set.I will send a PR.
Linked PRs
typing.NoDefaultis final #149411typing.NoDefaultis final (GH-149411) #149419typing.NoDefaultis final (GH-149411) #149420