From 630a6cd9cfb3470e4fcddaf372905d6724316341 Mon Sep 17 00:00:00 2001 From: Arthur Pastel Date: Tue, 29 Oct 2024 16:11:28 +0100 Subject: [PATCH 1/2] chore: drop support for python3.8 --- .github/workflows/ci.yml | 3 +-- README.md | 4 ++-- pyproject.toml | 5 ++--- 3 files changed, 5 insertions(+), 7 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 1ee2804..abd502b 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -33,12 +33,11 @@ jobs: - pytest-benchmark - valgrind python-version: - - "3.8" - "3.9" - "3.10" - "3.11" - "3.12" - - "3.13.0-rc.1" + - "3.13" pytest-version: - ">=8.1.1" diff --git a/README.md b/README.md index 21c7633..2aa5264 100644 --- a/README.md +++ b/README.md @@ -3,7 +3,7 @@ [![CI](https://github.com/CodSpeedHQ/pytest-codspeed/actions/workflows/ci.yml/badge.svg)](https://github.com/CodSpeedHQ/pytest-codspeed/actions/workflows/ci.yml) [![PyPi Version](https://img.shields.io/pypi/v/pytest-codspeed?color=%2334D058&label=pypi)](https://pypi.org/project/pytest-codspeed) -![Python Version](https://img.shields.io/badge/python-3.8%20|%203.9%20|%203.10%20|%203.11%20|%203.12%20|%203.13-informational.svg) +![Python Version](https://img.shields.io/badge/python-3.9%20|%203.10%20|%203.11%20|%203.12%20|%203.13-informational.svg) [![Discord](https://img.shields.io/badge/chat%20on-discord-7289da.svg)](https://discord.com/invite/MxpaCfKSqF) [![CodSpeed Badge](https://img.shields.io/endpoint?url=https://codspeed.io/badge.json)](https://codspeed.io/CodSpeedHQ/pytest-codspeed) @@ -13,7 +13,7 @@ Pytest plugin to create CodSpeed benchmarks ## Requirements -**Python**: 3.8 and later +**Python**: 3.9 and later **pytest**: any recent version diff --git a/pyproject.toml b/pyproject.toml index 85e0144..1ee3167 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -13,7 +13,7 @@ dynamic = ["version"] description = "Pytest plugin to create CodSpeed benchmarks" readme = "README.md" license = { file = "LICENSE" } -requires-python = ">=3.8" +requires-python = ">=3.9" authors = [{ name = "Arthur Pastel", email = "arthur@codspeed.io" }] keywords = ["codspeed", "benchmark", "performance", "pytest"] classifiers = [ @@ -23,7 +23,6 @@ classifiers = [ "Intended Audience :: Information Technology", "License :: OSI Approved :: MIT License", "Programming Language :: Python :: 3", - "Programming Language :: Python :: 3.8", "Programming Language :: Python :: 3.9", "Programming Language :: Python :: 3.10", "Programming Language :: Python :: 3.11", @@ -65,7 +64,7 @@ features = ["lint", "test", "compat"] features = ["test"] [[tool.hatch.envs.test.matrix]] -python = ["3.8", "3.9", "3.10", "3.11", "3.12", "3.13"] +python = ["3.9", "3.10", "3.11", "3.12", "3.13"] features = ["compat", "test"] [tool.hatch.version] From c7fca17faf594bfe242ebe803710b8d355c43b40 Mon Sep 17 00:00:00 2001 From: Arthur Pastel Date: Tue, 29 Oct 2024 17:33:13 +0100 Subject: [PATCH 2/2] fix: fix compatibility with pytest-benchmark 5.0.0 Induced by https://github.com/ionelmc/pytest-benchmark/commit/d6511e3474931feb4e862948128e0c389acfceec --- .github/workflows/ci.yml | 16 +++++++++++----- pyproject.toml | 2 +- src/pytest_codspeed/plugin.py | 12 ++++++++++++ 3 files changed, 24 insertions(+), 6 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index abd502b..f8ebbf2 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -30,7 +30,8 @@ jobs: matrix: config: - headless - - pytest-benchmark + - pytest-benchmark-4 + - pytest-benchmark-5 - valgrind python-version: - "3.9" @@ -51,10 +52,15 @@ jobs: name: Install valgrind run: sudo apt-get install valgrind -y - name: Install dependencies with pytest${{ matrix.pytest-version }} - run: pip install .[dev,compat,build] "pytest${{ matrix.pytest-version }}" - - if: matrix.config != 'pytest-benchmark' - name: Uninstall pytest-benchmark - run: pip uninstall -y pytest-benchmark + run: | + pip install .[dev,compat,build] "pytest${{ matrix.pytest-version }}" + pip uninstall -y pytest-benchmark + - if: matrix.config == 'pytest-benchmark-4' + name: Install pytest-benchmark 4.0.0 + run: pip install pytest-benchmark~=4.0.0 + - if: matrix.config == 'pytest-benchmark-5' + name: Install pytest-benchmark 5.0.0 + run: pip install pytest-benchmark~=5.0.0 - name: Run tests run: pytest -vs diff --git a/pyproject.toml b/pyproject.toml index 1ee3167..93d8d4f 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -48,7 +48,7 @@ dependencies = [ build = ["semver>=3.0.2"] lint = ["mypy ~= 1.11.2", "ruff ~= 0.6.5"] compat = [ - "pytest-benchmark ~= 4.0.0", + "pytest-benchmark ~= 5.0.0", "pytest-xdist ~= 3.6.1", # "pytest-speed>=0.3.5", ] diff --git a/src/pytest_codspeed/plugin.py b/src/pytest_codspeed/plugin.py index f86e47d..881b27d 100644 --- a/src/pytest_codspeed/plugin.py +++ b/src/pytest_codspeed/plugin.py @@ -320,6 +320,18 @@ def pytest_sessionfinish(session: pytest.Session, exitstatus): class BenchmarkFixture: """The fixture that can be used to benchmark a function.""" + @property # type: ignore + def __class__(self): + # Bypass the pytest-benchmark fixture class check + # https://github.com/ionelmc/pytest-benchmark/commit/d6511e3474931feb4e862948128e0c389acfceec + if IS_PYTEST_BENCHMARK_INSTALLED: + from pytest_benchmark.fixture import ( + BenchmarkFixture as PytestBenchmarkFixture, + ) + + return PytestBenchmarkFixture + return BenchmarkFixture + def __init__(self, request: pytest.FixtureRequest): self.extra_info: dict = {}