Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: pytest-benchmark 5.0.0 compatibility #54

Merged
merged 2 commits into from
Oct 29, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 12 additions & 7 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -30,15 +30,15 @@ jobs:
matrix:
config:
- headless
- pytest-benchmark
- pytest-benchmark-4
- pytest-benchmark-5
- 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"

Expand All @@ -52,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

Expand Down
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand All @@ -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

Expand Down
7 changes: 3 additions & 4 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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 = [
Expand All @@ -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",
Expand All @@ -49,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",
]
Expand All @@ -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]
Expand Down
12 changes: 12 additions & 0 deletions src/pytest_codspeed/plugin.py
Original file line number Diff line number Diff line change
Expand Up @@ -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 = {}

Expand Down
Loading