MCPcopy Index your code
hub / github.com/RustPython/RustPython / test_can_subclass

Method test_can_subclass

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

Source from the content-addressed store, hash-verified

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

Callers

nothing calls this directly

Calls 7

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

Tested by

no test coverage detected