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

Method test_basic_protocol

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

Source from the content-addressed store, hash-verified

2853
2854class ProtocolTests(BaseTestCase):
2855 def test_basic_protocol(self):
2856 @runtime_checkable
2857 class P(Protocol):
2858 def meth(self):
2859 pass
2860
2861 class C: pass
2862
2863 class D:
2864 def meth(self):
2865 pass
2866
2867 def f():
2868 pass
2869
2870 self.assertIsSubclass(D, P)
2871 self.assertIsInstance(D(), P)
2872 self.assertNotIsSubclass(C, P)
2873 self.assertNotIsInstance(C(), P)
2874 self.assertNotIsSubclass(types.FunctionType, P)
2875 self.assertNotIsInstance(f, P)
2876
2877 def test_runtime_checkable_generic_non_protocol(self):
2878 # Make sure this doesn't raise AttributeError

Callers

nothing calls this directly

Calls 6

assertIsInstanceMethod · 0.80
assertNotIsInstanceMethod · 0.80
DClass · 0.70
CClass · 0.70
assertIsSubclassMethod · 0.45
assertNotIsSubclassMethod · 0.45

Tested by

no test coverage detected