Skip to content
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

do not use setup.cfg file that does not have tox:tox namespace #1045

Closed
williamjamir opened this issue Oct 8, 2018 · 10 comments · Fixed by #1642
Closed

do not use setup.cfg file that does not have tox:tox namespace #1045

williamjamir opened this issue Oct 8, 2018 · 10 comments · Fixed by #1642
Labels
area:configuration feature:new something does not exist yet, but should help:wanted Issues that have been acknowledged, a solution determined and a PR might likely be accepted. level:medium rought estimate that this might be neither easy nor hard to implement
Milestone

Comments

@williamjamir
Copy link

williamjamir commented Oct 8, 2018

Hi,

I would like to suggest a check to ensure that a tox.ini file is present when calling the tox command.

I'm saying this because by mistake I've named the file tox.ini as .tox.ini and took me a time to figure it out the problem.

The build had five stages:

py27, py36, py37, linting, docs

Link for the Travis build with all stages listed

The stages py27, py36, py37 was marked as "successful", even though nothing was tested.
Link for the job py37

While the stages linting and docs were raising an Error

ERROR: unknown environment 'linting'

I believe that this type of information leads to misinterpretation since the user could believe that the configuration is ok (because the py* was marked as successful) and the problem is related with the "linting/docs" stage.

@gaborbernat
Copy link
Member

gaborbernat commented Oct 8, 2018

@williamjamir at the moment if we fail to find a configuration fail we stop with error and the message:

tox
ERROR: tox config file (either pyproject.toml, tox.ini, setup.cfg) not found

If you did not get it means you most probably had a tox.ini file discovered by following the rules from https://tox.readthedocs.io/en/latest/config.html#configuration-discovery.

Furthermore, if you call tox with a verbose flag you'll see explicitly stated what config is used (we recommend passing at least one verbosity in CI to help debug when things fail):

tox -v
using tox.ini: /home/bernat/git/tox/tox.ini
using tox-3.5.0 from /home/bernat/.local/lib/python3.7/site-packages/tox/__init__.py

The tools/checks are already there I think, you just need to use it. Let me know if you need anything else.

@gaborbernat gaborbernat added the type:question a question about how things work or if something is a bug or a feature label Oct 8, 2018
@williamjamir
Copy link
Author

williamjamir commented Oct 8, 2018

Thanks for the answer @gaborbernat =)
I've added the flag -v and as you have mentioned, another file was being used as the configuration for tox.

$ tox -v
using tox.ini: /home/travis/build/williamjamir/test-cookiecutter/setup.cfg
ERROR: unknown environment 'linting'

On the documentation the following note is added:

Note that setup.cfg requires the content to be under the tox:tox section.

My setup.cfg file has the following content:

[bdist_wheel]
universal = 1

[flake8]
exclude = docs

[aliases]
test = pytest

[tool:pytest]
collect_ignore = ['setup.py']

Perhaps the existence of the tox:tox section, inside the setup.cfg, should be verified as well

@gaborbernat
Copy link
Member

gaborbernat commented Oct 8, 2018

Indeed it should, not sure how trivial it is to added will have a look. Feel free to shoot a pr if you have time for it.

@gaborbernat gaborbernat changed the title Ensure that a tox.ini file exist do not use setup.cfg file that does not have tox:tox namespace Oct 8, 2018
@gaborbernat gaborbernat added feature:new something does not exist yet, but should area:configuration level:medium rought estimate that this might be neither easy nor hard to implement and removed type:question a question about how things work or if something is a bug or a feature labels Oct 8, 2018
@gaborbernat gaborbernat added this to the 3.6 milestone Oct 8, 2018
@gaborbernat gaborbernat modified the milestones: 3.6, 3.7 Dec 16, 2018
@gaborbernat gaborbernat added the help:wanted Issues that have been acknowledged, a solution determined and a PR might likely be accepted. label May 3, 2019
@hroncok
Copy link
Contributor

hroncok commented Aug 5, 2020

This now surprised me as well. In Fedora, we promote the use of tox in RPM tests and "no tests found, but exit code 0" is something I'd like to avoid because it creates a false sense of being tested ("oh, this package runs tox and the build passed, all is 🦄 🌈").

I'll try to have a look on how to solve this, no timeline thou.

hroncok added a commit to hroncok/tox that referenced this issue Aug 6, 2020
When tox is invoked without a tox configuration file (and without command line
options that could be used instead), it fails with:

    $ tox
    ERROR: tox config file (either pyproject.toml, tox.ini, setup.cfg) not found

This is useful: If there is no config, test didn't run and such error should
not pass silently.

However, until this commit, when there was a setup.cfg file it was considered
as a tox config even when there was no [tox:tox] section:

    $ tox
    GLOB sdist-make: .../setup.py
    python create: .../.tox/python
    python inst: ...
    python installed: ...
    python run-test-pre: PYTHONHASHSEED='1234567890'
    ___________________________________ summary ____________________________________
      python: commands succeeded
      congratulations :)

That is not safe, because setup.cfg can exist even if there is no tox
configuration in it and teh success creates a false sense of safety.

To fix this and to match the behavior of pyproject.toml without a tox section,
tox now skips setup.cfg, if there is no [tox:tox] section.

Fixes tox-dev#1045
hroncok added a commit to hroncok/tox that referenced this issue Aug 6, 2020
When tox is invoked without a tox configuration file (and without command line
options that could be used instead), it fails with:

    $ tox
    ERROR: tox config file (either pyproject.toml, tox.ini, setup.cfg) not found

This is useful: If there is no config, test didn't run and such error should
not pass silently.

However, until this commit, when there was a setup.cfg file it was considered
as a tox config even when there was no [tox:tox] section:

    $ tox
    GLOB sdist-make: .../setup.py
    python create: .../.tox/python
    python inst: ...
    python installed: ...
    python run-test-pre: PYTHONHASHSEED='1234567890'
    ___________________________________ summary ____________________________________
      python: commands succeeded
      congratulations :)

That is not safe, because setup.cfg can exist even if there is no tox
configuration in it and the success creates a false sense of safety.

To fix this and to match the behavior of pyproject.toml without a tox section,
tox now skips setup.cfg, if there is no [tox:tox] section.

Fixes tox-dev#1045
@hroncok
Copy link
Contributor

hroncok commented Aug 6, 2020

Here #1642

@gaborbernat
Copy link
Member

gaborbernat commented Aug 6, 2020

Released via https://pypi.org/project/tox/3.19.0/

@devmcp
Copy link

devmcp commented Aug 13, 2020

This update breaks system.cfg files that use [tox], rather than [tox:tox], giving the following error:

ERROR: tox config file (either pyproject.toml, tox.ini, setup.cfg) not found

Was this intentional?

@hroncok
Copy link
Contributor

hroncok commented Aug 13, 2020

I was following the documentation in here.

@hroncok
Copy link
Contributor

hroncok commented Aug 13, 2020

Sorry for the brief comment previously. According to the docs, the configuration in setup.cfg must be namespaced as [tox:tox]. If that was not the case, we can certainly allow [tox] as well and document it.

@gaborbernat
Copy link
Member

gaborbernat commented Aug 13, 2020

I think it's intentional breaking here.

@tox-dev tox-dev locked and limited conversation to collaborators Jan 14, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
area:configuration feature:new something does not exist yet, but should help:wanted Issues that have been acknowledged, a solution determined and a PR might likely be accepted. level:medium rought estimate that this might be neither easy nor hard to implement
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants