-
-
Notifications
You must be signed in to change notification settings - Fork 2.7k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Documentation request: types/shapes of options in [tool.pytest.ini_options]
#12228
Comments
[tool.pytest.ini_options]
[tool.pytest.ini_options]
FWIW per my observations My understanding is that the types of settings are the same as in |
Thank you very much @webknjaz. Another related question you might know: In [tool:pytest]
addopts =
# show 10 slowest invocations:
--durations=10
# a bit of verbosity doesn't hurt:
-v (e.g. https://github.com/aio-libs/aiohttp/blob/v3.9.5/setup.cfg#L117-L136) Does it mean that something like the following in [tool.pytest.ini_options]
addopts = """
# show 10 slowest invocations:
--durations=10
# a bit of verbosity doesn't hurt:
-v
""" |
I haven't tried it but I'd expect that the comments are handled on the structured config parsing level. And in your example, they are within a string. That's one of the reasons I use a Though, I'm guessing here. I haven't checked how the TOML parsing behaves in any of my projects 🤷♂️ |
coments in strings wont wotk - the ini parser hanlders the comments, the toml version just puts the values in place the plan is to eventually replace it with real toml data |
Thank you very much for the clarifications, I will adopt the follow approach in
Probably it is still a good idea to document types/shapes that are acceptable as TOML (the |
What's the problem this feature will solve?
Currently the docs mention that you can use
[tool.pytest.ini_options]
for configuringpytest
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 astring
"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 topytest.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
The text was updated successfully, but these errors were encountered: