-
-
Notifications
You must be signed in to change notification settings - Fork 526
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
Using non-existent environment does not fail #2858
Comments
Looks like this is a regression as with tox v3...
|
This is expected 😊 and feature with tox 4. |
I was not specific enough. Above output is from tox version 3. tox version 4 falsly runs tests for an unknown env. So... This is not intended, right? |
It is intended. I refer to it as the on-demand definition of new tox environments. Allows you to test never python versions without defining them in the config.
Well, that depends on the config, 😊 you might define basepython in testenv, and in that case will run with that python. |
While I am happy to allow this for e.g. |
There's no easy way to allow just one and not the other. I am mainly considering factors like a-py313-ok. But feel free to put in a PR to try. |
I bumped into this issue when I removed an environment from the |
It's undocumented in either direction. |
This may not matter unless this issue is worked on, but I'm even seeing some strange behavior here with tox 3.28.0. For this tox.ini file:
I get this:
If I add a value for envlist to the above file, this no longer happens. For
I get:
This behavior resulted in the CI config for a project I work on not running the tests we expect for months. I suspect many other people are unknowingly bitten by behavior like this. I think more sanity checking on environment names could provide a lot of value. |
This is a trade off between flexibility of on demand envs and too much validation. |
A workaround could be to add a default testenv that always fails:
This requires the actual test commands to be in a section like I agree with some people earlier in this issue that it would be a better default tradeoff if only |
Expanding on the above a bit, the approach I'm currently using is:
|
PR welcome 👍 |
I've been looking at this a little bit. I see the code that handled this in 3.28.0, but it's not immediately clear to me where the equivalent code should go with the 4.0 refactoring. Any pointers would be much appreciated. |
Hit this today, and was initially surprised that passing an unknown recipe From reading the above, I see now it provides a back door to testing on newer Python versions. A few ideas here:
|
For the record, this trips me up all the time. Some projects I work on have a "static" testenv, others call it "static-charm" or "pyright" or similar. When I type |
I opened a PR following the suggestion to disallow implicit environment creation outside of the special case for I'm curious if it would be better to create a configuration option to opt in to this behavior since this change seems like it could break backwards compatibility for some. Suggestions for improvement are welcomed 👍. |
Ah nuts. We were relying on this behaviour. (ALL THE CI THINGS broke today...) In particular it:
For example: [tox]
minversion = 3.24
envlist =
test
lint
isolated_build = True
skip_missing_interpreters = True
[testenv]
commands =
test: python -m pytest --junitxml=test-reports/pytest.{envname}.xml --cov-report xml:test-reports/coverage.{envname}.xml {posargs}
lint-!py27: pre-commit run --all-files
lint-py27: pre-commit run --all-files --config .pre-commit-config.27.yaml (pseudo) Jenkinsfile: dynamicMatrix(
[
platform: ['linux','windows'],
python: ['27', '38', '310'], // add python versions here
]) {
...
stage(cell) {
sh label: "test", script: "tox -e test-py${python}-${platform}"
sh label: "lint", script: "tox -e lint-py${python}-${platform}"
}
} While I understand the argument for rejecting Now I guess the alternative is we write: [tox]
minversion = 4.9
envlist =
{test,lint}-py{27,38,310,311}-{linux,windows} And retrain those who are used to running Is there a better way? |
PR welcome to accept this. |
I found a workaround, which is to put the And then realised that, humorously, this means that |
A couple thoughts:
|
Issue
Using an environment that does not exist still executes without failure but does nothing useful.
Environment
Provide at least:
pip list
of the host Python wheretox
is installed:Minimal example
If possible, provide a minimal reproducer for the issue:
tox run -e abcdefg
The text was updated successfully, but these errors were encountered: