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

Method test_can_subclass

Lib/test/test_typing.py:123–140  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

121 Any[int] # Any is not a generic type.
122
123 def test_can_subclass(self):
124 class Mock(Any): pass
125 self.assertIsSubclass(Mock, Any)
126 self.assertIsInstance(Mock(), Mock)
127
128 class Something: pass
129 self.assertNotIsSubclass(Something, Any)
130 self.assertNotIsInstance(Something(), Mock)
131
132 class MockSomething(Something, Mock): pass
133 self.assertIsSubclass(MockSomething, Any)
134 self.assertIsSubclass(MockSomething, MockSomething)
135 self.assertIsSubclass(MockSomething, Something)
136 self.assertIsSubclass(MockSomething, Mock)
137 ms = MockSomething()
138 self.assertIsInstance(ms, MockSomething)
139 self.assertIsInstance(ms, Something)
140 self.assertIsInstance(ms, Mock)
141
142 def test_subclassing_with_custom_constructor(self):
143 class Sub(Any):

Callers

nothing calls this directly

Calls 7

MockSomethingClass · 0.85
assertIsSubclassMethod · 0.80
assertIsInstanceMethod · 0.80
assertNotIsSubclassMethod · 0.80
assertNotIsInstanceMethod · 0.80
MockClass · 0.70
SomethingClass · 0.70

Tested by

no test coverage detected