From 1832d023d76e8c44533e759d520e599b2aa73a60 Mon Sep 17 00:00:00 2001 From: Jesse Hills <3060199+jesserockz@users.noreply.github.com> Date: Thu, 25 Jun 2026 14:18:52 +1200 Subject: [PATCH] [tests] Cover the libretiny branch of the interactive wizard MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The interactive wizard's platform / board-link / boards-list elif chain includes an ``elif platform == "RP2":`` arm that ``test_wizard_accepts_rpipico_board`` exercises on the True side. Without an interactive wizard test that reaches those elifs with a non-RP2 platform, the False side stayed uncovered and codecov flagged the line as a partial branch. Add ``test_wizard_accepts_default_answers_bk72xx`` — same fixture shape as the existing ESP32 / ESP8266 variants — so the BK72XX path falls through the RP2 elifs and pins both branches. --- tests/unit_tests/test_wizard.py | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) diff --git a/tests/unit_tests/test_wizard.py b/tests/unit_tests/test_wizard.py index edb1b4cb9c..244e4eb5a1 100644 --- a/tests/unit_tests/test_wizard.py +++ b/tests/unit_tests/test_wizard.py @@ -476,6 +476,34 @@ def test_wizard_accepts_default_answers_esp32( assert retval == 0 +def test_wizard_accepts_default_answers_bk72xx( + tmp_path: Path, monkeypatch: MonkeyPatch, wizard_answers: list[str] +): + """ + The wizard should accept the given default answers for bk72xx. The + libretiny branch also exercises the False side of the + ``elif platform == "RP2":`` checks in the platform / board-link + elif chain (without this, those branches show as partial coverage + because only the rpipico interactive test reaches them with platform + == "RP2"). + """ + # Given + wizard_answers[1] = "BK72XX" + wizard_answers[2] = next(iter(BK72XX_BOARD_PINS)) + config_file = tmp_path / "test.yaml" + input_mock = MagicMock(side_effect=wizard_answers) + monkeypatch.setattr("builtins.input", input_mock) + monkeypatch.setattr(wz, "safe_print", lambda t=None, end=None: 0) + monkeypatch.setattr(wz, "sleep", lambda _: 0) + monkeypatch.setattr(wz, "wizard_write", MagicMock()) + + # When + retval = wz.wizard(config_file) + + # Then + assert retval == 0 + + def test_wizard_offers_better_node_name( tmp_path: Path, monkeypatch: MonkeyPatch, wizard_answers: list[str] ):