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

Method test_object_class

Lib/test/test_descr.py:1021–1043  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

1019 type, "ConfusedGrid", (HVGrid, VHGrid), {})
1020
1021 def test_object_class(self):
1022 # Testing object class...
1023 a = object()
1024 self.assertEqual(a.__class__, object)
1025 self.assertEqual(type(a), object)
1026 b = object()
1027 self.assertNotEqual(a, b)
1028 self.assertNotHasAttr(a, "foo")
1029 try:
1030 a.foo = 12
1031 except (AttributeError, TypeError):
1032 pass
1033 else:
1034 self.fail("object() should not allow setting a foo attribute")
1035 self.assertNotHasAttr(object(), "__dict__")
1036
1037 class Cdict(object):
1038 pass
1039 x = Cdict()
1040 self.assertEqual(x.__dict__, {})
1041 x.foo = 1
1042 self.assertEqual(x.foo, 1)
1043 self.assertEqual(x.__dict__, {'foo': 1})
1044
1045 def test_object_class_assignment_between_heaptypes_and_nonheaptypes(self):
1046 class SubType(types.ModuleType):

Callers

nothing calls this directly

Calls 5

CdictClass · 0.85
assertNotEqualMethod · 0.80
assertNotHasAttrMethod · 0.80
assertEqualMethod · 0.45
failMethod · 0.45

Tested by

no test coverage detected