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

Method test_dynamic_class_creation

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

Source from the content-addressed store, hash-verified

1953 self.assertTrue(t[0] is not dd) # make sure defaultdict is copied
1954
1955 def test_dynamic_class_creation(self):
1956 cls_dict = {'__annotations__': {'x': int, 'y': int},
1957 }
1958
1959 # Create the class.
1960 cls = type('C', (), cls_dict)
1961
1962 # Make it a dataclass.
1963 cls1 = dataclass(cls)
1964
1965 self.assertEqual(cls1, cls)
1966 self.assertEqual(asdict(cls(1, 2)), {'x': 1, 'y': 2})
1967
1968 def test_dynamic_class_creation_using_field(self):
1969 cls_dict = {'__annotations__': {'x': int, 'y': int},

Callers

nothing calls this directly

Calls 4

assertEqualMethod · 0.95
dataclassFunction · 0.85
asdictFunction · 0.85
clsClass · 0.50

Tested by

no test coverage detected