Skip to content

Commit 1207d64

Browse files
ilevkivskyilisroach
authored andcommitted
bpo-28556: Add a regression test to typing (pythonGH-15396)
This adds a regression test for the issue found in the Python 2 backport, see python/typing#656 https://bugs.python.org/issue28556
1 parent 8f849ea commit 1207d64

File tree

1 file changed

+17
-0
lines changed

1 file changed

+17
-0
lines changed

Lib/test/test_typing.py

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -961,6 +961,23 @@ def __init__(self, x):
961961
self.assertIsInstance(C(1), P)
962962
self.assertIsInstance(C(1), PG)
963963

964+
def test_protocol_checks_after_subscript(self):
965+
class P(Protocol[T]): pass
966+
class C(P[T]): pass
967+
class Other1: pass
968+
class Other2: pass
969+
CA = C[Any]
970+
971+
self.assertNotIsInstance(Other1(), C)
972+
self.assertNotIsSubclass(Other2, C)
973+
974+
class D1(C[Any]): pass
975+
class D2(C[Any]): pass
976+
CI = C[int]
977+
978+
self.assertIsInstance(D1(), C)
979+
self.assertIsSubclass(D2, C)
980+
964981
def test_protocols_support_register(self):
965982
@runtime_checkable
966983
class P(Protocol):

0 commit comments

Comments
 (0)