MCPcopy Index your code
hub / github.com/python/cpython / test_missing_default

Method test_missing_default

Lib/test/test_dataclasses/__init__.py:944–963  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

942 )
943
944 def test_missing_default(self):
945 # Test that MISSING works the same as a default not being
946 # specified.
947 @dataclass
948 class C:
949 x: int=field(default=MISSING)
950 with self.assertRaisesRegex(TypeError,
951 r'__init__\(\) missing 1 required '
952 'positional argument'):
953 C()
954 self.assertNotIn('x', C.__dict__)
955
956 @dataclass
957 class D:
958 x: int
959 with self.assertRaisesRegex(TypeError,
960 r'__init__\(\) missing 1 required '
961 'positional argument'):
962 D()
963 self.assertNotIn('x', D.__dict__)
964
965 def test_missing_default_factory(self):
966 # Test that MISSING works the same as a default factory not

Callers

nothing calls this directly

Calls 4

assertRaisesRegexMethod · 0.95
assertNotInMethod · 0.95
CClass · 0.70
DClass · 0.70

Tested by

no test coverage detected