I am trying to setup the pytest.ini configuration file such that any benchmark test runs with the "--benchmark-autosave" option as on and other tests do not.
I have tried adding the option in the ini file as follows...
[pytest]
addopts = --benchmark-autosave
However it runs this option with every tests resulting in PytestBenchmarkWarning warnings. I am wondering if there is a way just to run this option on pytests that have benchmark used.
I have looked into...
[pytest]
addopts = --benchmark-autosave
filterwarnings =
ignore::PytestBenchmarkWarning
However, I get this error:
INTERNALERROR> warnings. OptionError: unknown warning category: 'PytestBenchmarkWarning'
If I have the tests as follows test_a.py
import a
import pytest
def test_a(benchmark):
benchmark(a.func)
test_b.py
import b
import pytest
def test_b():
b.func()
pytest.ini
[pytest]
addopts = --benchmark-autosave
filterwarnings =
ignore::PytestBenchmarkWarning
with file structure:
my_project/src/a.py
my_project/src/b.py
my_project/test/test_a.py
my_project/test/test_b.py
my_project/pytest.ini
Under a terminal:
cd my_project
pytest test/