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.
This commit is contained in:
Christian Kellner 2022-08-04 16:38:06 +02:00
parent bf2789fd91
commit 620f7c0f3e

View file

@ -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)