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

Method test_protocols_isinstance_py36

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

Source from the content-addressed store, hash-verified

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