bpo-38908: Fix issue when non runtime_protocol failed to raise TypeError (#26067)

This commit is contained in:
Yurii Karabas 2021-05-12 18:47:49 +03:00 committed by GitHub
parent 9b06e4b535
commit c40486a32d
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 23 additions and 2 deletions

View file

@ -1422,6 +1422,14 @@ class ProtocolTests(BaseTestCase):
class CustomContextManager(typing.ContextManager, Protocol):
pass
def test_non_runtime_protocol_isinstance_check(self):
class P(Protocol):
x: int
with self.assertRaisesRegex(TypeError, "@runtime_checkable"):
isinstance(1, P)
class GenericTests(BaseTestCase):
def test_basics(self):