diff --git a/ci/custom_linters.py b/ci/custom_linters.py index 7743e53e8..adb90dfbf 100644 --- a/ci/custom_linters.py +++ b/ci/custom_linters.py @@ -8,11 +8,10 @@ import yaml -def _ci_patterns() -> set[str]: +def _ci_patterns(repository_root: Path) -> set[str]: """ Return the CI patterns given in the CI configuration file. """ - repository_root = Path(__file__).parent.parent ci_file = repository_root / ".github" / "workflows" / "ci.yml" github_workflow_config = yaml.safe_load(ci_file.read_text()) matrix = github_workflow_config["jobs"]["build"]["strategy"]["matrix"] @@ -50,12 +49,12 @@ def _tests_from_pattern( return tests -def test_ci_patterns_valid() -> None: +def test_ci_patterns_valid(request: pytest.FixtureRequest) -> None: """ All of the CI patterns in the CI configuration match at least one test in the test suite. """ - ci_patterns = _ci_patterns() + ci_patterns = _ci_patterns(repository_root=request.config.rootpath) for ci_pattern in ci_patterns: collect_only_result = pytest.main( @@ -82,13 +81,14 @@ def test_ci_patterns_valid() -> None: def test_tests_collected_once( capsys: pytest.CaptureFixture[str], + request: pytest.FixtureRequest, ) -> None: """ Each test in the test suite is collected exactly once. This does not necessarily mean that they are run - they may be skipped. """ - ci_patterns = _ci_patterns() + ci_patterns = _ci_patterns(repository_root=request.config.rootpath) tests_to_patterns: dict[str, set[str]] = {} for pattern in ci_patterns: diff --git a/tests/mock_vws/test_docker.py b/tests/mock_vws/test_docker.py index 3ada889ad..836f79b24 100644 --- a/tests/mock_vws/test_docker.py +++ b/tests/mock_vws/test_docker.py @@ -6,7 +6,6 @@ import uuid from http import HTTPStatus -from pathlib import Path from typing import TYPE_CHECKING import docker # type: ignore[import-untyped] @@ -105,12 +104,13 @@ def fixture_custom_bridge_network() -> Iterator[Network]: def test_build_and_run( high_quality_image: io.BytesIO, custom_bridge_network: Network, + request: pytest.FixtureRequest, ) -> None: """ It is possible to build Docker images which combine to make a working mock application. """ - repository_root = Path(__file__).parent.parent.parent + repository_root = request.config.rootpath client = docker.from_env() dockerfile = repository_root / "src/mock_vws/_flask_server/Dockerfile"