Skip to content

Documentation request: types/shapes of options in [tool.pytest.ini_options] #12228

Open
@abravalheri

Description

@abravalheri

What's the problem this feature will solve?

Currently the docs mention that you can use [tool.pytest.ini_options] for configuring pytest but they don't specify which "type"/"shape" of TOML object can be associated with each option. Instead, there is just a small example with 3 options.

That is a bit confusing, because users don't know what is the best way of writing the correct values to add to pyproject.toml.

One example of such confusion in particular is addopts.
From the example in the docs, I currently interpret that addopts should be a string "object".
However, after a quick search on GitHub, I can also see that there is several projects using an array of strings for that option (so I suppose that also works). However, that brings another question: can I use an array of strings for addopts, but written in a way that each string contain multiple "arguments" (e.g.: addopts = ["--verbose", "-p no:cov", '-m "not integration"'])?

Describe the solution you'd like

Ideally either https://docs.pytest.org/en/8.0.x/reference/customize.html#pyproject-toml or https://docs.pytest.org/en/8.0.x/reference/reference.html#configuration-options should tell the users what are all the possibilities for encoding an specific configuration in pyproject.toml in addition to pytest.ini/setup.cfg/tox.ini.

Considering the example above, it would be great if the docs explicitly tell that addopts accepts wither an string or array of strings and that in the case the user decides to write an array of strings, each string should be a single "argument".

Alternative Solutions

Additional context

Metadata

Metadata

Assignees

No one assigned

    Labels

    topic: configrelated to config handling, argument parsing and config filetype: docsdocumentation improvement, missing or needing clarification

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions