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 from .. import test
@pytest.mark.skipif(not test.TestBase.have_test_checkout(), "no test-checkout access") @pytest.fixture(name="source_files")
def test_pylint(): def discover_source_files():
# if not test.TestBase.have_test_checkout():
# Run `pylint` on all python sources. We simply use `find` to locate pytest.skip("no test-checkout access")
# all `*.py` files, and then manually select the reverse-domain named
# modules we have.
#
checkout = test.TestBase.locate_test_checkout() checkout = test.TestBase.locate_test_checkout()
@ -45,5 +42,14 @@ def test_pylint():
# Append the checkout-path so all paths are absolute. # Append the checkout-path so all paths are absolute.
files = map(lambda p: os.path.join(checkout, p), files) files = map(lambda p: os.path.join(checkout, p), files)
# Run pylint on all files. return list(files)
subprocess.run(["pylint"] + list(files), check=True)
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)