Skip to content

Commit d135104

Browse files
The-Compilerionelmc
authored andcommitted
1 parent 4a99afe commit d135104

4 files changed

Lines changed: 12 additions & 8 deletions

File tree

AUTHORS.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,3 +32,4 @@ Authors
3232
* Dimitris Rozakis - https://github.com/dimrozakis
3333
* Friedrich Delgado - https://github.com/TauPan
3434
* Sam James - https://github.com/thesamesam
35+
* Florian Bruhin - https://github.com/The-Compiler

CHANGELOG.rst

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,9 @@ Changelog
66
------------------
77
* Fix skipping test in `test_utils.py` if appropriate VCS not available. Also fix typo.
88
Contributed by Sam James in `#211 <https://github.com/ionelmc/pytest-benchmark/pull/211>`_.
9+
* Use ``pytest.hookimpl`` and ``pytest.hookspec`` to configure hooks,
10+
avoiding a deprecation warning in the upcoming pytest 7.2.0.
11+
Contributed by Florian Bruhin in `#224 <https://github.com/ionelmc/pytest-benchmark/pull/224>`_.
912

1013
3.4.2 (2021-06-15)
1114
------------------

src/pytest_benchmark/hookspec.py

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
1+
import pytest
2+
3+
@pytest.hookspec(firstresult=True)
14
def pytest_benchmark_scale_unit(config, unit, benchmarks, best, worst, sort):
25
"""
36
To have custom time scaling do something like this:
@@ -19,6 +22,7 @@ def pytest_benchmark_scale_unit(config, unit, benchmarks, best, worst, sort):
1922
pass
2023

2124

25+
@pytest.hookspec(firstresult=True)
2226
def pytest_benchmark_generate_machine_info(config):
2327
"""
2428
To completely replace the generated machine_info do something like this:
@@ -45,6 +49,7 @@ def pytest_benchmark_update_machine_info(config, machine_info):
4549
pass
4650

4751

52+
@pytest.hookspec(firstresult=True)
4853
def pytest_benchmark_generate_commit_info(config):
4954
"""
5055
To completely replace the generated commit_info do something like this:
@@ -69,6 +74,7 @@ def pytest_benchmark_update_commit_info(config, commit_info):
6974
pass
7075

7176

77+
@pytest.hookspec(firstresult=True)
7278
def pytest_benchmark_group_stats(config, benchmarks, group_by):
7379
"""
7480
You may perform grouping customization here, in case the builtin grouping doesn't suit you.
@@ -90,6 +96,7 @@ def pytest_benchmark_group_stats(config, benchmarks, group_by):
9096
pass
9197

9298

99+
@pytest.hookspec(firstresult=True)
93100
def pytest_benchmark_generate_json(config, benchmarks, include_data, machine_info, commit_info):
94101
"""
95102
You should read pytest-benchmark's code if you really need to wholly customize the json.
@@ -143,10 +150,3 @@ def pytest_benchmark_compare_machine_info(config, benchmarksession, machine_info
143150
)
144151
"""
145152
pass
146-
147-
148-
pytest_benchmark_scale_unit.firstresult = True
149-
pytest_benchmark_generate_commit_info.firstresult = True
150-
pytest_benchmark_generate_json.firstresult = True
151-
pytest_benchmark_generate_machine_info.firstresult = True
152-
pytest_benchmark_group_stats.firstresult = True

src/pytest_benchmark/plugin.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -434,7 +434,7 @@ def pytest_runtest_makereport(item, call):
434434
fixture.skipped = outcome.get_result().outcome == 'skipped'
435435

436436

437-
@pytest.mark.trylast # force the other plugins to initialise, fixes issue with capture not being properly initialised
437+
@pytest.hookimpl(trylast=True) # force the other plugins to initialise, fixes issue with capture not being properly initialised
438438
def pytest_configure(config):
439439
config.addinivalue_line("markers", "benchmark: mark a test with custom benchmark settings.")
440440
bs = config._benchmarksession = BenchmarkSession(config)

0 commit comments

Comments
 (0)