Skip to content

Commit 90eaf66

Browse files
committed
apply reviews
1 parent bb569ca commit 90eaf66

File tree

1 file changed

+12
-7
lines changed
  • codeflash-benchmark/codeflash_benchmark

1 file changed

+12
-7
lines changed

codeflash-benchmark/codeflash_benchmark/plugin.py

Lines changed: 12 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -36,9 +36,16 @@ def pytest_configure(config: pytest.Config) -> None:
3636
"""Register the benchmark marker and disable conflicting plugins."""
3737
config.addinivalue_line("markers", "benchmark: mark test as a benchmark that should be run with codeflash tracing")
3838

39-
if config.getoption("--codeflash-trace") and PYTEST_BENCHMARK_INSTALLED:
40-
config.pluginmanager.set_blocked("pytest_benchmark")
41-
config.pluginmanager.set_blocked("pytest-benchmark")
39+
if config.getoption("--codeflash-trace"):
40+
# When --codeflash-trace is used, ignore all benchmark options by resetting them to defaults
41+
for option, _, default, _ in benchmark_options:
42+
option_name = option.replace("--", "").replace("-", "_")
43+
if hasattr(config.option, option_name):
44+
setattr(config.option, option_name, default)
45+
46+
if PYTEST_BENCHMARK_INSTALLED:
47+
config.pluginmanager.set_blocked("pytest_benchmark")
48+
config.pluginmanager.set_blocked("pytest-benchmark")
4249

4350

4451
def pytest_addoption(parser: pytest.Parser) -> None:
@@ -47,9 +54,7 @@ def pytest_addoption(parser: pytest.Parser) -> None:
4754
)
4855
# These options are ignored when --codeflash-trace is used
4956
for option, action, default, help_text in benchmark_options:
50-
help_suffix = (
51-
" (ignored when --codeflash-trace is used)" if "disable" not in option and "skip" not in option else ""
52-
)
57+
help_suffix = " (ignored when --codeflash-trace is used)"
5358
parser.addoption(option, action=action, default=default, help=help_text + help_suffix)
5459

5560

@@ -65,7 +70,7 @@ def benchmark(request: pytest.FixtureRequest) -> object:
6570
# If pytest-benchmark is installed and --codeflash-trace is not enabled,
6671
# return the normal pytest-benchmark fixture
6772
if PYTEST_BENCHMARK_INSTALLED:
68-
from pytest_benchmark.fixture import BenchmarkFixture as BSF # noqa: N814
73+
from pytest_benchmark.fixture import BenchmarkFixture as BSF # pyright: ignore[reportMissingImports] # noqa: I001, N814
6974

7075
bs = getattr(config, "_benchmarksession", None)
7176
if bs and bs.skip:

0 commit comments

Comments
 (0)