python
config_error
ai_generated
true
ERROR: /path/pytest.ini:1: unexpected line: '[tool:pytest]' # or: pyproject.toml: no [tool.pytest.ini_options] section found
ID: python/pytest-config-error-nested-ini
80%Fix Rate
86%Confidence
0Evidence
2025-03-10First Seen
Version Compatibility
| Version | Status | Introduced | Deprecated | Notes |
|---|---|---|---|---|
| 7.x | active | — | — | — |
| 8.x | active | — | — | — |
Root Cause
The [tool:pytest] section was written in pytest.ini (which expects [pytest]), or the pyproject.toml lacks the required [tool.pytest.ini_options] header.
generic中文
在 pytest.ini 中写入了 [tool:pytest] 段(应使用 [pytest]),或 pyproject.toml 缺少必需的 [tool.pytest.ini_options] 头。
Workarounds
-
98% success
# pytest.ini [pytest] addopts = -ra # pyproject.toml [tool.pytest.ini_options] addopts = '-ra' # setup.cfg [tool:pytest] addopts = -ra
-
90% success
ls pytest.ini tox.ini setup.cfg pyproject.toml # Keep exactly one with the correct section; delete or empty the others.
Dead Ends
Common approaches that don't work:
-
75% fail
pytest reads only one config file and ignores the duplicate; the parse error remains or config is silently dropped.
-
60% fail
setup.cfg expects [tool:pytest] but other tools may also read it; renaming alone does not fix the section header inside.