Skip to content

Commit

Permalink
Merge pull request #5 from tlambert03/fix-win
Browse files Browse the repository at this point in the history
fix: Fix windows keybindings tests
  • Loading branch information
tlambert03 committed Jun 29, 2022
2 parents 7233dcf + 73908f1 commit 25359ff
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 6 deletions.
13 changes: 9 additions & 4 deletions src/app_model/_types.py
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,12 @@ class KeybindingRuleDict(TypedDict, total=False):
# ------------------ commands-related types --------------------


class Icon(BaseModel):
class _StrictModel(BaseModel):
class Config:
extra = "forbid"


class Icon(_StrictModel):
"""Icons used to represent commands, or submenus.
May provide both a light and dark variant. If only one is provided, it is used
Expand Down Expand Up @@ -87,7 +92,7 @@ def validate(cls, v: Any) -> Icon:
return cls(**v)


class CommandRule(BaseModel):
class CommandRule(_StrictModel):
"""Data representing a command and its presentation.
Presentation of contributed commands depends on the containing menu. The Command
Expand Down Expand Up @@ -132,7 +137,7 @@ class CommandRule(BaseModel):
# ------------------ keybinding-related types --------------------


class KeybindingRule(BaseModel):
class KeybindingRule(_StrictModel):
"""Data representing a keybinding and when it should be active.
This model lacks a corresponding command. That gets linked up elsewhere,
Expand Down Expand Up @@ -174,7 +179,7 @@ def _bind_to_current_platform(self) -> Optional[KeyCodeStr]:
# ------------------ menus-related types --------------------


class _MenuItemBase(BaseModel):
class _MenuItemBase(_StrictModel):
"""Data representing where and when a menu item should be shown."""

when: Optional[context.Expr] = Field(
Expand Down
2 changes: 1 addition & 1 deletion tests/test_actions.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
dict(keybindings=[{"primary": PRIMARY_KEY}]),
dict(
keybindings=[
{"primary": PRIMARY_KEY, "mac": OS_KEY, "windows": OS_KEY, "linux": OS_KEY}
{"primary": PRIMARY_KEY, "mac": OS_KEY, "win": OS_KEY, "linux": OS_KEY}
]
),
dict(keybindings=[{"primary": "ctrl+a"}], menus=[{"id": MENUID}]),
Expand Down
10 changes: 10 additions & 0 deletions tests/test_id.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
import os
import platform
import sys


def test_plat():
print(f"{os.name=}")
print(f"{sys.platform=}")
print(f"{platform.system()=}")
print(f"{platform.release()=}")
2 changes: 1 addition & 1 deletion tox.ini
Original file line number Diff line number Diff line change
Expand Up @@ -26,4 +26,4 @@ setenv =
extras =
test
commands =
pytest -v --cov=app_model --cov-report=xml --color=yes --basetemp={envtmpdir} {posargs}
pytest -v -s --cov=app_model --cov-report=xml --color=yes --basetemp={envtmpdir} {posargs}

0 comments on commit 25359ff

Please sign in to comment.