Regression in environment var inheritance in tox 4 #2831
Labels
bug:minor
does not affect many people or has no big impact
help:wanted
Issues that have been acknowledged, a solution determined and a PR might likely be accepted.
Issue
I'm not sure if this is a regression, or if I am using a bad pattern that worked by chance in tox3.
I use the base [testenv] to set_env some vars and run unit tests. Then I have a [testenv:functional] that inherits these env vars (most of which are still relevant) but changes the var governing where the tests are located. I use that as an "abstract" testenv to hold the setenv, commands, etc., for python-version-specific testenvs like [testenv:functional-py39], [testenv:functional-py310], etc. In tox3 this worked great, but in tox 4, the changes to set_env in the "abstract" testenv aren't picked up when I call 'tox -e functional-py39'.
Here's a
tox.ini
for this that works in both tox3 and tox4.All
ts.sh
does is echo the value of the env var of interest to a file:Using the
tox.ini
with both tox3 and tox4:Looking at the created file:
You can see that tox3 uses the correct value for the env var for the functional tests, but tox4 is using the original value.
Environment
Provide at least:
pip list
of the host Python wheretox
is installed:Output of running tox
Provide the output of
tox -rvv
:Minimal example
If possible, provide a minimal reproducer for the issue:
(see file above)
Observations
The "abstract" testenv is necessary, that is, the bug isn't reproducible if you just have 2 testenvs.
I think this may have something to do with lazy loading of environments in tox4, because the bug doesn't occur if we use that intermediate "abstract" environment:
... though, of course, the whole point of the "abstract" testenv is that you normally don't use it directly.
This seems kind of bad to me, because people not using the "abstract" testenv will still see misleading results from the 'tox c' output. In other words, if you only had [testenv] and [testenv:functional] defined (forget about the "abstract" business), 'tox c' does not show the value that tox is actually using for OS_TEST_PATH when you call 'tox -e functional', which makes debugging the config file difficult.
The text was updated successfully, but these errors were encountered: