Skip to content

Commit

Permalink
Added tests against an empty protocol
Browse files Browse the repository at this point in the history
Closes #491.
  • Loading branch information
agronholm committed Nov 3, 2024
1 parent 1c53caa commit b32af0b
Showing 1 changed file with 14 additions and 0 deletions.
14 changes: 14 additions & 0 deletions tests/test_checkers.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand Down

0 comments on commit b32af0b

Please sign in to comment.