From b32af0bffb52c0b80f2c781656fb67ae1de87947 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Alex=20Gr=C3=B6nholm?= Date: Sun, 3 Nov 2024 14:00:16 +0200 Subject: [PATCH] Added tests against an empty protocol Closes #491. --- tests/test_checkers.py | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/tests/test_checkers.py b/tests/test_checkers.py index 23e01aa..1ba0407 100644 --- a/tests/test_checkers.py +++ b/tests/test_checkers.py @@ -1199,6 +1199,20 @@ def my_class_method(x: int, y: str) -> None: else: check_type(Foo, type[MyProtocol]) + @pytest.mark.parametrize( + "instantiate", + [pytest.param(True, id="instance"), pytest.param(False, id="class")], + ) + @pytest.mark.parametrize("subject_class", [object, str, Parent]) + def test_empty_protocol(self, instantiate: bool, subject_class: type[Any]): + class EmptyProtocol(Protocol): + pass + + if instantiate: + check_type(subject_class(), EmptyProtocol) + else: + check_type(subject_class, type[EmptyProtocol]) + @pytest.mark.parametrize("has_member", [True, False]) def test_member_checks(self, has_member: bool) -> None: class MyProtocol(Protocol):