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

Method test_protocols_isinstance_py36

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

Source from the content-addressed store, hash-verified

3703 self.assertIsInstance(HasNothingButSlots(), HasX)
3704
3705 def test_protocols_isinstance_py36(self):
3706 class APoint:
3707 def __init__(self, x, y, label):
3708 self.x = x
3709 self.y = y
3710 self.label = label
3711
3712 class BPoint:
3713 label = 'B'
3714
3715 def __init__(self, x, y):
3716 self.x = x
3717 self.y = y
3718
3719 class C:
3720 def __init__(self, attr):
3721 self.attr = attr
3722
3723 def meth(self, arg):
3724 return 0
3725
3726 class Bad: pass
3727
3728 self.assertIsInstance(APoint(1, 2, 'A'), Point)
3729 self.assertIsInstance(BPoint(1, 2), Point)
3730 self.assertNotIsInstance(MyPoint(), Point)
3731 self.assertIsInstance(BPoint(1, 2), Position)
3732 self.assertIsInstance(Other(), Proto)
3733 self.assertIsInstance(Concrete(), Proto)
3734 self.assertIsInstance(C(42), Proto)
3735 self.assertNotIsInstance(Bad(), Proto)
3736 self.assertNotIsInstance(Bad(), Point)
3737 self.assertNotIsInstance(Bad(), Position)
3738 self.assertNotIsInstance(Bad(), Concrete)
3739 self.assertNotIsInstance(Other(), Concrete)
3740 self.assertIsInstance(NT(1, 2), Position)
3741
3742 def test_protocols_isinstance_init(self):
3743 T = TypeVar('T')

Callers

nothing calls this directly

Calls 10

APointClass · 0.85
BPointClass · 0.85
MyPointClass · 0.85
NTClass · 0.85
assertIsInstanceMethod · 0.80
assertNotIsInstanceMethod · 0.80
OtherClass · 0.70
ConcreteClass · 0.70
CClass · 0.70
BadClass · 0.70

Tested by

no test coverage detected