def test_typed_dict_mypy_extension(self): TDOld = METypedDict("TDOld", {'x': int, 'y': int}) self.assertEqual(typed_dict_keys(TDM), {'x': int, 'y': int}) self.assertEqual(typed_dict_keys(TDOld), {'x': int, 'y': int}) self.assertIs(typed_dict_keys(dict), None) self.assertIs(typed_dict_keys(Other), None) self.assertIsNot(typed_dict_keys(TDM), TDM.__annotations__)
def test_typed_dict(self): TDOld = TypedDict("TDOld", {'x': int, 'y': int}) self.assertEqual(typed_dict_keys(TD), {'x': int, 'y': int}) self.assertEqual(typed_dict_keys(TDOld), {'x': int, 'y': int}) self.assertIs(typed_dict_keys(dict), None) self.assertIs(typed_dict_keys(Other), None) self.assertIsNot(typed_dict_keys(TD), TD.__annotations__)
def test_python_type(self, field: 'RecordType'): assert typed_dict_keys(field.python_type) == { 'foo': Union[bytes, memoryview, bytearray], 'bar': c_uint64, }