Skip to content

--config-file incorrectly expects [tool.pytest] instead of [pytest] in TOML config on pytest 9 #14705

Description

@francis-clairicia

Description

After a migration from a custom config file pytest-benchmark.ini:

[pytest]
python_files = bench_*.py
python_classes = Bench
python_functions = bench_*
addopts =
    --strict-markers
    --benchmark-warmup=on
    --benchmark-warmup-iterations=10000
    --benchmark-timer=time.process_time
    --benchmark-time-unit=us
    --benchmark-min-time=0.000002
    --benchmark-sort=fullname
    --benchmark-disable-gc
minversion = 7.4
testpaths = benchmarks

... to pytest-benchmark.toml with the help of the documentation:

[pytest]
minversion = "9.0"
python_files = ["bench_*.py"]
python_classes = ["Bench"]
python_functions = ["bench_*"]
strict_config = true
strict_markers = true
strict_parametrization_ids = true
addopts = [
    "--benchmark-warmup=on",
    "--benchmark-warmup-iterations=10000",
    "--benchmark-timer=time.process_time",
    "--benchmark-time-unit=us",
    "--benchmark-min-time=0.000002",
    "--benchmark-sort=fullname",
    "--benchmark-disable-gc",
]
testpaths = ["benchmarks"]

... launching pytest -c pytest-benchmark.toml --collect-only ignores the benchmark files defined and uses the default configuration values.

I tried to put the configuration in [tool.pytest] and it worked:

- [pytest]
+ [tool.pytest]
minversion = "9.0"
python_files = ["bench_*.py"]
python_classes = ["Bench"]
python_functions = ["bench_*"]
strict_config = true
strict_markers = true
strict_parametrization_ids = true
addopts = [
    "--benchmark-warmup=on",
    "--benchmark-warmup-iterations=10000",
    "--benchmark-timer=time.process_time",
    "--benchmark-time-unit=us",
    "--benchmark-min-time=0.000002",
    "--benchmark-sort=fullname",
    "--benchmark-disable-gc",
]
testpaths = ["benchmarks"]

Environment

  • pytest: 9.1.1
  • OS: Linux

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions