Skip to content

Commit 6318314

Browse files
committed
Fix bad fixture check. Close #271.
1 parent 614df44 commit 6318314

File tree

4 files changed

+61
-7
lines changed

4 files changed

+61
-7
lines changed

pytest.ini

+1
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ addopts =
2525
--ignore=src/pytest_benchmark/pep418.py
2626
--doctest-modules
2727
--doctest-glob=\*.rst
28+
--nbmake
2829
--tb=short
2930
testpaths =
3031
tests

src/pytest_benchmark/plugin.py

+4-2
Original file line numberDiff line numberDiff line change
@@ -510,10 +510,12 @@ def pytest_runtest_setup(item):
510510
@pytest.hookimpl(hookwrapper=True)
511511
def pytest_runtest_makereport(item, call):
512512
outcome = yield
513-
fixture = hasattr(item, 'funcargs') and item.funcargs.get('benchmark')
513+
fixture = None
514+
if hasattr(item, 'funcargs'):
515+
fixture = item.funcargs.get('benchmark')
514516
if fixture is not None and not isinstance(fixture, BenchmarkFixture):
515517
raise TypeError(
516-
f'unexpected type for `benchmark` in funcargs, {fixture!r} must be a BenchmarkFixture instance.'
518+
f'unexpected type for `benchmark` in funcargs, {fixture!r} must be a BenchmarkFixture instance. '
517519
'You should not use other plugins that define a `benchmark` fixture, or return and unexpected value if you do redefine it.'
518520
)
519521
if fixture:

tests/test_nbmake.ipynb

+50
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
{
2+
"cells": [
3+
{
4+
"cell_type": "code",
5+
"id": "initial_id",
6+
"metadata": {
7+
"collapsed": true,
8+
"ExecuteTime": {
9+
"end_time": "2024-10-30T00:19:36.564972Z",
10+
"start_time": "2024-10-30T00:19:36.560019Z"
11+
}
12+
},
13+
"source": [
14+
"a = 1\n",
15+
"print(a)"
16+
],
17+
"outputs": [
18+
{
19+
"name": "stdout",
20+
"output_type": "stream",
21+
"text": [
22+
"1\n"
23+
]
24+
}
25+
],
26+
"execution_count": 1
27+
}
28+
],
29+
"metadata": {
30+
"kernelspec": {
31+
"display_name": "Python 3",
32+
"language": "python",
33+
"name": "python3"
34+
},
35+
"language_info": {
36+
"codemirror_mode": {
37+
"name": "ipython",
38+
"version": 2
39+
},
40+
"file_extension": ".py",
41+
"mimetype": "text/x-python",
42+
"name": "python",
43+
"nbconvert_exporter": "python",
44+
"pygments_lexer": "ipython2",
45+
"version": "2.7.6"
46+
}
47+
},
48+
"nbformat": 4,
49+
"nbformat_minor": 5
50+
}

tox.ini

+6-5
Original file line numberDiff line numberDiff line change
@@ -40,8 +40,8 @@ usedevelop =
4040
cover: true
4141
nocov: false
4242
deps =
43-
pytest-instafail==0.4.2
44-
xdist: pytest-xdist==2.5.0
43+
pytest-instafail==0.5.0
44+
xdist: pytest-xdist==3.6.1
4545
pytest71: pytest==7.1.3
4646
pytest72: pytest==7.2.2
4747
pytest73: pytest==7.3.2
@@ -54,12 +54,13 @@ deps =
5454
cover: coverage
5555
pypy: jitviewer
5656
aspectlib==2.0.0
57-
pygal==3.0.4
57+
pygal==3.0.5
5858
pygaljs==1.0.2
59-
freezegun==1.3.1
59+
freezegun==1.5.1
6060
hunter
6161
setuptools
62-
elasticsearch==8.11.1
62+
elasticsearch==8.15.1
63+
nbmake==1.5.4
6364
commands =
6465
nocov: {posargs:pytest -vv --ignore=src}
6566
cover: {posargs:pytest --cov --cov-report=term-missing --cov-report=xml -vv}

0 commit comments

Comments
 (0)