Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: Fix windows keybindings tests #5

Merged
merged 3 commits into from
Jun 29, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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}