Move the logic of providing testfs out of the tests and into a fixture. Pytest-modules that prepare testing data in their own fixtures should build on top of this.
Tests using the fixture will be skipped if the feature is unavailable; remove that check from existing tests. Signed-off-by: Jonas Rebmann <j...@pengutronix.de> --- conftest.py | 8 ++++++++ test/py/test_fit.py | 5 +---- 2 files changed, 9 insertions(+), 4 deletions(-) diff --git a/conftest.py b/conftest.py index 00969e62df..116beb5d14 100644 --- a/conftest.py +++ b/conftest.py @@ -231,3 +231,11 @@ def strategy(request, target, pytestconfig): strategy.force(state) return strategy + +@pytest.fixture(scope="session") +def testfs(strategy, env): + if "testfs" not in env.get_target_features(): + pytest.skip("testfs not supported on this platform") + + path = os.path.join(os.environ["LG_BUILDDIR"], "testfs") + return path diff --git a/test/py/test_fit.py b/test/py/test_fit.py index 08d5feba5c..3b2b8ff871 100644 --- a/test/py/test_fit.py +++ b/test/py/test_fit.py @@ -15,10 +15,7 @@ def generate_bootscript(barebox, image, name="test"): return name -def test_fit(barebox, env, target, barebox_config): - if 'testfs' not in env.get_target_features(): - pytest.xfail("testfs feature not specified") - +def test_fit(barebox, env, target, barebox_config, testfs): _, _, returncode = barebox.run(f"ls {fit_name('gzipped')}") if returncode != 0: pytest.xfail("skipping test due to missing FIT image") -- 2.51.0.297.gca2559c1d6