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 https://github.com/python/typing/issues/656

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

Co-authored-by: Ivan Levkivskyi <levkivskyi@gmail.com>
This commit is contained in:
Miss Islington (bot) 2019-08-22 11:11:27 -07:00 committed by GitHub
parent cb8de91dad
commit 5fda09cc1e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 17 additions and 0 deletions

View File

@ -961,6 +961,23 @@ class ProtocolTests(BaseTestCase):
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):