diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 25b11c8..8d13451 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -33,12 +33,17 @@ jobs: - pytest-benchmark - valgrind python-version: - - "3.7" - "3.8" - "3.9" - "3.10" - "3.11" - "3.12" + pytest-version: + - ">=8.1.1" + include: + - config: pytest-benchmark + python-version: "3.7" + pytest-version: "<8.1.1" steps: - uses: actions/checkout@v4 @@ -49,10 +54,18 @@ jobs: - if: matrix.config == 'valgrind' || matrix.config == 'pytest-benchmark' name: Install valgrind run: sudo apt-get install valgrind -y - - name: Install dependencies - run: pip install .[dev,compat] + - name: Install dependencies with pytest${{ matrix.pytest-version }} + run: pip install .[dev,compat] "pytest${{ matrix.pytest-version }}" - if: matrix.config != 'pytest-benchmark' name: Uninstall pytest-benchmark run: pip uninstall -y pytest-benchmark - name: Run tests run: pytest -vs + + all-checks: + runs-on: ubuntu-latest + steps: + - run: echo "All CI checks passed." + needs: + - static-analysis + - tests diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 0f71438..953997a 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -8,15 +8,12 @@ repos: - id: end-of-file-fixer - id: check-yaml - id: check-added-large-files - - repo: https://github.com/psf/black - rev: 22.3.0 - hooks: - - id: black - repo: https://github.com/pre-commit/mirrors-mypy rev: v1.3.0 hooks: - id: mypy - - repo: https://github.com/charliermarsh/ruff-pre-commit - rev: v0.0.275 + - repo: https://github.com/astral-sh/ruff-pre-commit + rev: v0.3.3 hooks: - id: ruff + - id: ruff-format diff --git a/pyproject.toml b/pyproject.toml index 8f56f9e..9032d69 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -44,7 +44,7 @@ dependencies = [ ] [project.optional-dependencies] -lint = ["black ~= 23.3.0", "isort ~=5.12.0", "mypy ~= 1.3.0", "ruff ~= 0.0.275"] +lint = ["mypy ~= 1.3.0", "ruff ~= 0.3.3"] compat = ["pytest-benchmark ~= 4.0.0", "pytest-xdist ~= 2.0.0"] test = ["pytest ~= 7.0", "pytest-cov ~= 4.0.0"] @@ -73,6 +73,7 @@ python_version = "3.12" [tool.ruff] line-length = 88 +[tool.ruff.lint] select = ["E", "F", "I", "C"] [tool.isort] diff --git a/src/pytest_codspeed/plugin.py b/src/pytest_codspeed/plugin.py index 13d8e97..24dc656 100644 --- a/src/pytest_codspeed/plugin.py +++ b/src/pytest_codspeed/plugin.py @@ -28,6 +28,7 @@ IS_PYTEST_BENCHMARK_INSTALLED = pkgutil.find_loader("pytest_benchmark") is not None SUPPORTS_PERF_TRAMPOLINE = sys.version_info >= (3, 12) +BEFORE_PYTEST_8_1_1 = pytest.version_tuple < (8, 1, 1) @pytest.hookimpl(trylast=True) @@ -95,15 +96,18 @@ def pytest_plugin_registered(plugin, manager: "pytest.PytestPluginManager"): codspeed_plugin: CodSpeedPlugin = manager.get_plugin(PLUGIN_NAME) if codspeed_plugin.is_codspeed_enabled: codspeed_benchmark_fixtures = plugin.getfixturedefs( - "codspeed_benchmark", "" + "codspeed_benchmark", + fixture_manager.session.nodeid + if BEFORE_PYTEST_8_1_1 + else fixture_manager.session, ) assert codspeed_benchmark_fixtures is not None - fixture_manager._arg2fixturedefs[ - "__benchmark" - ] = fixture_manager._arg2fixturedefs["benchmark"] - fixture_manager._arg2fixturedefs["benchmark"] = list( - codspeed_benchmark_fixtures + # Archive the pytest-benchmark fixture + fixture_manager._arg2fixturedefs["__benchmark"] = ( + fixture_manager._arg2fixturedefs["benchmark"] ) + # Replace the pytest-benchmark fixture with the codspeed one + fixture_manager._arg2fixturedefs["benchmark"] = codspeed_benchmark_fixtures @pytest.hookimpl(trylast=True) diff --git a/tests/test_pytest_plugin.py b/tests/test_pytest_plugin.py index ce83032..2997f08 100644 --- a/tests/test_pytest_plugin.py +++ b/tests/test_pytest_plugin.py @@ -142,7 +142,7 @@ class TestGroup: def setup_method(self): print(); print("Setup called") - def teardown(self): + def teardown_method(self): print(); print("Teardown called") @pytest.mark.benchmark