From 142c3d3e1a2e2f9a9ead43b5722346e3b79c1832 Mon Sep 17 00:00:00 2001 From: Francois Beutin Date: Fri, 21 Feb 2025 14:20:18 +0100 Subject: [PATCH 1/2] Use new setup feature from ragger --- .../workflows/build_and_functional_tests.yml | 2 +- tests/ragger/conftest.py | 31 ++++--------------- tests/ragger/test_clone.py | 3 ++ 3 files changed, 10 insertions(+), 26 deletions(-) diff --git a/.github/workflows/build_and_functional_tests.yml b/.github/workflows/build_and_functional_tests.yml index 65ebfa0cd..f72e6cc65 100644 --- a/.github/workflows/build_and_functional_tests.yml +++ b/.github/workflows/build_and_functional_tests.yml @@ -59,5 +59,5 @@ jobs: download_app_binaries_artifact: "ragger_elfs" additional_app_binaries_artifact: "clone_elfs" additional_app_binaries_artifact_dir: ./tests/ragger/.test_dependencies/clone/build/ - test_options: "--with_lib_mode" + test_options: "--setup lib_mode" regenerate_snapshots: ${{ inputs.golden_run == 'Open a PR' }} diff --git a/tests/ragger/conftest.py b/tests/ragger/conftest.py index 2f1eac38c..f3ddde95e 100644 --- a/tests/ragger/conftest.py +++ b/tests/ragger/conftest.py @@ -18,33 +18,14 @@ # ragger.configuration.OPTIONAL_CONFIGURATION # Please refer to ragger/conftest/configuration.py for their descriptions and accepted values +configuration.OPTIONAL.ALLOWED_SETUPS = ["default", "lib_mode"] -def pytest_addoption(parser): - parser.addoption("--with_lib_mode", action="store_true", help="Run the test with Library Mode") - -pattern = f"{Path(__file__).parent}/test_*.py" -testFiles = [path.basename(x) for x in glob.glob(pattern)] -collect_ignore = [] -if "--with_lib_mode" in sys.argv: - - # ============================================================================== - # /!\ Tests are started in Library mode: unselect (ignore) unrelated modules /!\ - # ============================================================================== - - warnings.warn("Main app is started in library mode") - - configuration.OPTIONAL.MAIN_APP_DIR = "tests/ragger/.test_dependencies/" - - collect_ignore += [f for f in testFiles if "test_clone" not in f] - -else: - - # =========================================================================== - # /!\ Standards tests without Library mode: unselect (ignore) clone tests /!\ - # =========================================================================== - - collect_ignore += [f for f in testFiles if "test_clone" in f] +def pytest_configure(config): + current_setup = config.getoption("--setup") + if current_setup == "lib_mode": + warnings.warn("Main app is started in library mode") + configuration.OPTIONAL.MAIN_APP_DIR = "tests/ragger/.test_dependencies/" @pytest.fixture(name="app_version") diff --git a/tests/ragger/test_clone.py b/tests/ragger/test_clone.py index 4419227fb..f3770bc09 100644 --- a/tests/ragger/test_clone.py +++ b/tests/ragger/test_clone.py @@ -1,3 +1,5 @@ +import pytest + from pathlib import Path from web3 import Web3 @@ -19,6 +21,7 @@ # Transfer on Clone app +@pytest.mark.needs_setup('lib_mode') def test_clone_thundercore(firmware: Firmware, backend: BackendInterface, navigator: Navigator, From da965f5274735207f1652cbb6adbda7427e28344 Mon Sep 17 00:00:00 2001 From: Francois Beutin Date: Fri, 21 Feb 2025 15:15:46 +0100 Subject: [PATCH 2/2] Allow running pytest from the project root --- pytest.ini | 4 ++++ 1 file changed, 4 insertions(+) create mode 100644 pytest.ini diff --git a/pytest.ini b/pytest.ini new file mode 100644 index 000000000..49fc0d8d6 --- /dev/null +++ b/pytest.ini @@ -0,0 +1,4 @@ +[pytest] +testpaths = tests/ragger +pythonpath = tests/ragger +addopts = tests/ragger