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

Method test_protocols_isinstance_init

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

Source from the content-addressed store, hash-verified

3740 self.assertIsInstance(NT(1, 2), Position)
3741
3742 def test_protocols_isinstance_init(self):
3743 T = TypeVar('T')
3744
3745 @runtime_checkable
3746 class P(Protocol):
3747 x = 1
3748
3749 @runtime_checkable
3750 class PG(Protocol[T]):
3751 x = 1
3752
3753 class C:
3754 def __init__(self, x):
3755 self.x = x
3756
3757 self.assertIsInstance(C(1), P)
3758 self.assertIsInstance(C(1), PG)
3759
3760 def test_protocols_isinstance_monkeypatching(self):
3761 @runtime_checkable

Callers

nothing calls this directly

Calls 2

assertIsInstanceMethod · 0.80
CClass · 0.70

Tested by

no test coverage detected