Skip to content

Commit 0018e59

Browse files
authored
Merge pull request #684 from codeflash-ai/pytest-benchmark-err-fix
Fix duplicate benchmark option registration when pytest-benchmark is installed
2 parents fdd7ca9 + d2ece1e commit 0018e59

File tree

1 file changed

+5
-4
lines changed
  • codeflash-benchmark/codeflash_benchmark

1 file changed

+5
-4
lines changed

codeflash-benchmark/codeflash_benchmark/plugin.py

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -52,10 +52,11 @@ def pytest_addoption(parser: pytest.Parser) -> None:
5252
parser.addoption(
5353
"--codeflash-trace", action="store_true", default=False, help="Enable CodeFlash tracing for benchmarks"
5454
)
55-
# These options are ignored when --codeflash-trace is used
56-
for option, action, default, help_text in benchmark_options:
57-
help_suffix = " (ignored when --codeflash-trace is used)"
58-
parser.addoption(option, action=action, default=default, help=help_text + help_suffix)
55+
# Only add benchmark options if pytest-benchmark is not installed for backward compatibility with existing pytest-benchmark setup
56+
if not PYTEST_BENCHMARK_INSTALLED:
57+
for option, action, default, help_text in benchmark_options:
58+
help_suffix = " (ignored when --codeflash-trace is used)"
59+
parser.addoption(option, action=action, default=default, help=help_text + help_suffix)
5960

6061

6162
@pytest.fixture

0 commit comments

Comments
 (0)