From 522f89cff9cefe5f0f15ba127e2c75b2f80bfc85 Mon Sep 17 00:00:00 2001 From: Marc Di Luzio Date: Mon, 12 Aug 2024 19:31:41 +0100 Subject: [PATCH] Fix instance tests --- py/matching.py | 11 ++++------- py/matching_test.py | 10 +++++++++- 2 files changed, 13 insertions(+), 8 deletions(-) diff --git a/py/matching.py b/py/matching.py index da74ee5..b526876 100644 --- a/py/matching.py +++ b/py/matching.py @@ -33,6 +33,10 @@ class Role(Protocol): def id(self) -> int: pass + @property + def name(self) -> str: + pass + @runtime_checkable class Member(Protocol): @@ -53,13 +57,6 @@ class Member(Protocol): pass -@runtime_checkable -class Role(Protocol): - @property - def name(self) -> str: - pass - - @runtime_checkable class Guild(Protocol): @property diff --git a/py/matching_test.py b/py/matching_test.py index 21f7c83..f9942de 100644 --- a/py/matching_test.py +++ b/py/matching_test.py @@ -17,7 +17,7 @@ def test_protocols(): assert isinstance(discord.Guild, matching.Guild) assert isinstance(discord.Role, matching.Role) assert isinstance(Member, matching.Member) - # assert isinstance(Role, matching.Role) + assert isinstance(Role, matching.Role) class Role(): @@ -28,6 +28,10 @@ class Role(): def id(self) -> int: return self._id + @property + def name(self) -> str: + pass + class Member(): def __init__(self, id: int, roles: list[Role] = []): @@ -38,6 +42,10 @@ class Member(): def mention(self) -> str: return f"<@{self._id}>" + @property + def display_name(self) -> str: + return f"{self._id}" + @property def roles(self) -> list[Role]: return self._roles