[Python-checkins] bpo-28556: Add a regression test to typing (GH-15396)

Miss Islington (bot) webhook-mailer at python.org
Thu Aug 22 13:48:14 EDT 2019


https://github.com/python/cpython/commit/8889627b53e1eea2e32590f1867fbb0b0fc7407f
commit: 8889627b53e1eea2e32590f1867fbb0b0fc7407f
branch: master
author: Ivan Levkivskyi <levkivskyi at gmail.com>
committer: Miss Islington (bot) <31488909+miss-islington at users.noreply.github.com>
date: 2019-08-22T10:48:01-07:00
summary:

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

files:
M Lib/test/test_typing.py

diff --git a/Lib/test/test_typing.py b/Lib/test/test_typing.py
index ba001c3462fc..ba0800fae90e 100644
--- a/Lib/test/test_typing.py
+++ b/Lib/test/test_typing.py
@@ -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):



More information about the Python-checkins mailing list