From b8655eb37778b8e570ba35dc1fe721e3a315e741 Mon Sep 17 00:00:00 2001 From: FBruzzesi Date: Mon, 10 Jun 2024 10:01:46 +0200 Subject: [PATCH] fairly ok coverage --- sksmithy/tui/_tui.py | 4 ++-- tests/test_tui.py | 13 +++++++------ 2 files changed, 9 insertions(+), 8 deletions(-) diff --git a/sksmithy/tui/_tui.py b/sksmithy/tui/_tui.py index 15511c4..ae47015 100644 --- a/sksmithy/tui/_tui.py +++ b/sksmithy/tui/_tui.py @@ -74,11 +74,11 @@ def compose(self: Self) -> ComposeResult: Footer(), ) - def action_toggle_dark(self: Self) -> None: + def action_toggle_dark(self: Self) -> None: # pragma: no cover """Toggle dark mode.""" self.dark = not self.dark - def action_toggle_sidebar(self: Self) -> None: + def action_toggle_sidebar(self: Self) -> None: # pragma: no cover """Toggle sidebar component.""" sidebar = self.query_one(Sidebar) self.set_focus(None) diff --git a/tests/test_tui.py b/tests/test_tui.py index 93edbcd..ea9c7d1 100644 --- a/tests/test_tui.py +++ b/tests/test_tui.py @@ -142,7 +142,8 @@ async def test_forge_raise() -> None: assert "The following parameters are invalid python identifiers: ('b b',)" in m3 -async def test_forge(tmp_path: Path) -> None: +@pytest.mark.parametrize("use_binding", [True, False]) +async def test_forge(tmp_path: Path, use_binding: bool) -> None: """Test forge button and all of its interactions.""" app = ForgeTUI() name = "MightyEstimator" @@ -164,14 +165,14 @@ async def test_forge(tmp_path: Path) -> None: await output_file_comp.action_submit() await pilot.pause() - forge_btn = pilot.app.query_one("#forge-btn", Button) - forge_btn.action_press() + if use_binding: + await pilot.press("F") + else: + forge_btn = pilot.app.query_one("#forge-btn", Button) + forge_btn.action_press() await pilot.pause() notification = next(iter(pilot.app._notifications)) # noqa: SLF001 assert f"Template forged at {output_file!s}" in notification.message assert output_file.exists() - - -def test_bindings() -> None: ...