summaryrefslogtreecommitdiffstats
path: root/Lib
diff options
context:
space:
mode:
authorIvan Levkivskyi <levkivskyi@gmail.com>2019-08-22 17:48:01 (GMT)
committerMiss Islington (bot) <31488909+miss-islington@users.noreply.github.com>2019-08-22 17:48:01 (GMT)
commit8889627b53e1eea2e32590f1867fbb0b0fc7407f (patch)
treea28a53f3be4dc5001f57753c8af6d1646afb7c98 /Lib
parentd0cdeaab76fef8a6e5a04665df226b6659111e4e (diff)
downloadcpython-8889627b53e1eea2e32590f1867fbb0b0fc7407f.zip
cpython-8889627b53e1eea2e32590f1867fbb0b0fc7407f.tar.gz
cpython-8889627b53e1eea2e32590f1867fbb0b0fc7407f.tar.bz2
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
Diffstat (limited to 'Lib')
-rw-r--r--Lib/test/test_typing.py17
1 files changed, 17 insertions, 0 deletions
diff --git a/Lib/test/test_typing.py b/Lib/test/test_typing.py
index ba001c3..ba0800f 100644
--- a/Lib/test/test_typing.py
+++ b/Lib/test/test_typing.py
@@ -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):