Skip to content

Commit

Permalink
Corrected some coverage issues with a late change to comparisons.
Browse files Browse the repository at this point in the history
  • Loading branch information
freakboy3742 committed Aug 12, 2023
1 parent f8c19b3 commit e0a46dc
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 5 deletions.
10 changes: 5 additions & 5 deletions core/src/toga/command.py
Original file line number Diff line number Diff line change
Expand Up @@ -102,17 +102,17 @@ def __hash__(self) -> int:
return hash(self.key)

def __lt__(self, other: Any) -> bool:
if not isinstance(other, [Group, Command]):
if not isinstance(other, (Group, Command)):
return False
return self.key < other.key

def __gt__(self, other: Any) -> bool:
if not isinstance(other, [Group, Command]):
if not isinstance(other, (Group, Command)):
return False
return other < self

def __eq__(self, other: Any) -> bool:
if not isinstance(other, [Group, Command]):
if not isinstance(other, (Group, Command)):
return False
return self.key == other.key

Expand Down Expand Up @@ -241,12 +241,12 @@ def icon(self, icon_or_name: str | Icon):
self._icon = Icon(icon_or_name)

def __lt__(self, other: Any) -> bool:
if not isinstance(other, [Group, Command]):
if not isinstance(other, (Group, Command)):
return False
return self.key < other.key

def __gt__(self, other: Any) -> bool:
if not isinstance(other, [Group, Command]):
if not isinstance(other, (Group, Command)):
return False
return other < self

Expand Down
6 changes: 6 additions & 0 deletions core/tests/command/test_command.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,12 @@ def assert_order(*items):
assert items[i] < items[j]
assert items[j] > items[i]

# For good measure; check comparisons with other types
assert not items[i] < None
assert not items[i] < 42
assert not items[i] > None
assert not items[i] > 42


@pytest.fixture
def app():
Expand Down

0 comments on commit e0a46dc

Please sign in to comment.