Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
bpo-28556: Add a regression test to typing (GH-15396)
This adds a regression test for the issue found in the Python 2 backport, see python/typing#656

https://bugs.python.org/issue28556
(cherry picked from commit 8889627)

Co-authored-by: Ivan Levkivskyi <levkivskyi@gmail.com>
  • Loading branch information
ilevkivskyi authored and miss-islington committed Aug 22, 2019
commit ff5109a092a029a53d79f89412e26ea27559b63f
17 changes: 17 additions & 0 deletions Lib/test/test_typing.py
Original file line number Diff line number Diff line change
Expand Up @@ -961,6 +961,23 @@ def __init__(self, x):
self.assertIsInstance(C(1), P)
self.assertIsInstance(C(1), PG)

def test_protocol_checks_after_subscript(self):
class P(Protocol[T]): pass
class C(P[T]): pass
class Other1: pass
class Other2: pass
CA = C[Any]

self.assertNotIsInstance(Other1(), C)
self.assertNotIsSubclass(Other2, C)

class D1(C[Any]): pass
class D2(C[Any]): pass
CI = C[int]

self.assertIsInstance(D1(), C)
self.assertIsSubclass(D2, C)

def test_protocols_support_register(self):
@runtime_checkable
class P(Protocol):
Expand Down