Skip to content
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
12 changes: 6 additions & 6 deletions src/app_model/types/_constants.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,18 +26,18 @@ def current() -> "OperatingSystem":

@property
def is_windows(self) -> bool:
"""Returns True if the current operating system is Windows."""
return _CURRENT == OperatingSystem.WINDOWS
"""Returns True if this operating system is Windows."""
return self == OperatingSystem.WINDOWS

@property
def is_linux(self) -> bool:
"""Returns True if the current operating system is Linux."""
return _CURRENT == OperatingSystem.LINUX
"""Returns True if this operating system is Linux."""
return self == OperatingSystem.LINUX

@property
def is_mac(self) -> bool:
"""Returns True if the current operating system is MacOS."""
return _CURRENT == OperatingSystem.MACOS
"""Returns True if this operating system is MacOS."""
return self == OperatingSystem.MACOS


_CURRENT = OperatingSystem.UNKNOWN
Expand Down
15 changes: 15 additions & 0 deletions tests/test_keybindings.py
Original file line number Diff line number Diff line change
Expand Up @@ -188,3 +188,18 @@ class M(BaseModel):

m = M(key=StandardKeyBinding.Copy)
assert m.key.primary == KeyMod.CtrlCmd | KeyCode.KeyC


@pytest.mark.parametrize(
("enc", "os", "expect"),
[
(KeyMod.CtrlCmd | KeyCode.KeyX, OperatingSystem.MACOS, "Cmd+X"),
(KeyMod.CtrlCmd | KeyCode.KeyX, OperatingSystem.WINDOWS, "Ctrl+X"),
(KeyMod.WinCtrl | KeyCode.KeyX, OperatingSystem.MACOS, "Control+X"),
(KeyMod.WinCtrl | KeyCode.KeyX, OperatingSystem.WINDOWS, "Win+X"),
],
)
def test_int_conversion_respects_os(enc: int, os: OperatingSystem, expect: str) -> None:
kb = KeyBinding.from_int(enc, os=os)
assert kb.to_text(os=os) == expect
assert kb.to_int(os=os) == enc
Loading