Pytest: support for [tool:pytest] given/other config files

Created on 21 Aug 2016  路  6Comments  路  Source: pytest-dev/pytest

With pytest -c setup.cfg the new [tool:pytest] section is not recognized.
I think it should be recognized for any config file (despite of its name/extension) that is passed in through -c. Ignoring the name here is important when using something like -c <(sed s/foo/bar/ setup.cfg) to pass in a temporary file (which won't have "setup.cfg" as its name).

Just add the following to a setup.cfg file and then run pytest -c setup.cfg:

[tool:pytest]
addopts = --meh

It won't complain about the unknown option --meh.

help wanted enhancement

Most helpful comment

Agreed [tool:pytest] is an improvement. I was attempting to use it while also specifying a config file and was confused that it didn't work. The documentation doesn't mention that it only works for auto-discovered things, and that should be fixed...or the feature should be extended to manually specified configs as well.

All 6 comments

right now tool:pytest is a special case only for setup.cfg coming in via autodiscovery

https://github.com/tox-dev/tox/issues/225 we should add it for tox ini as well

This is a bug, right? The documentation does not indicate that support for [tool:pytest] is consulted only when the config file is auto-discovered.

https://docs.pytest.org/en/latest/example/pythoncollection.html#changing-naming-conventions

@chebee7i its more of a change to enhance sanity - when it first was introduced it did the bad thing, and we want to change it to do a better thing

Agreed [tool:pytest] is an improvement. I was attempting to use it while also specifying a config file and was confused that it didn't work. The documentation doesn't mention that it only works for auto-discovered things, and that should be fixed...or the feature should be extended to manually specified configs as well.

this has been implemented

Was this page helpful?
0 / 5 - 0 ratings