From 620f7c0f3e4a35e58ce9b7682a98949dd97320b9 Mon Sep 17 00:00:00 2001 From: Christian Kellner Date: Thu, 4 Aug 2022 16:38:06 +0200 Subject: [PATCH] test/pylint: extract source files into fixture Extract the code that discovers the source files into a fixture; this is done so that we can share that other future tests. --- test/src/test_pylint.py | 24 +++++++++++++++--------- 1 file changed, 15 insertions(+), 9 deletions(-) diff --git a/test/src/test_pylint.py b/test/src/test_pylint.py index 51048b39..f6938bc2 100644 --- a/test/src/test_pylint.py +++ b/test/src/test_pylint.py @@ -10,13 +10,10 @@ import pytest from .. import test -@pytest.mark.skipif(not test.TestBase.have_test_checkout(), "no test-checkout access") -def test_pylint(): - # - # Run `pylint` on all python sources. We simply use `find` to locate - # all `*.py` files, and then manually select the reverse-domain named - # modules we have. - # +@pytest.fixture(name="source_files") +def discover_source_files(): + if not test.TestBase.have_test_checkout(): + pytest.skip("no test-checkout access") checkout = test.TestBase.locate_test_checkout() @@ -45,5 +42,14 @@ def test_pylint(): # Append the checkout-path so all paths are absolute. files = map(lambda p: os.path.join(checkout, p), files) - # Run pylint on all files. - subprocess.run(["pylint"] + list(files), check=True) + return list(files) + + +def test_pylint(source_files): + # + # Run `pylint` on all python sources. We simply use `find` to locate + # all `*.py` files, and then manually select the reverse-domain named + # modules we have. + # + + subprocess.run(["pylint"] + source_files, check=True)