Skip to content

pytest.toml without section header leads to silently ignored options #14638

Description

@The-Compiler

With this pytest.toml:

addopts = "-v"

pytest silently ignores the option without any sort of warning/error.

This is different to a pytest.ini, where

addopts = -v

leads to ERROR: .../pytest.ini:1: no section header defined.

One would think that a [pytest] header is not neaded at all, because sections (aka tables) are completely optional in toml, and with the config being in a pytest.toml (and not pyproject.toml), the [pytest] header is optional.

IMHO, we should go that way, and read the toplevel option without a section (and possibly even do so for pytest.ini, at least this is supported by configparser, not sure about inicfg).

Alternatively, pytest should warn/error about there being toplevel options it did not read.


Additionally, a similar issue exists with both TOML and ini if there is a typo in the section name. Again in pyproject.toml this makes perfect sense, but there is no reason there should be a [pytestt] section in either pytest.toml or pytest.ini. If I remember correctly there have been plugins (don't remember which) that have their own section in there and then read that out manually (without pytest's infrastructure), so maybe this should be a warning rather than an error.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions