Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Only return Python factor on base_python conflict
Consider the following 'tox.ini' file: [tox] ignore_base_python_conflict = true [testenv] base_python = python3 commands = ... [testenv:functional{,-py38,-py39,-py310}] commands = ... There is a conflict between the base_python value specified in '[testenv] base_python' and the value implied by the 'pyXY' factors in the 'functional-pyXY' test envs. The 'Python._validate_base_python' function is supposed to resolve this for us and either (a) raise an error if '[tox] ignore_base_python_conflict' is set to 'false' (default) or (b) ignore the value of '[testenv] base_python' in favour of the value implied by the 'pyXY' factor for the given test env if '[tox] ignore_base_python_conflict' is set to 'true'. There's a bug though. Rather than returning the 'pyXY' factor, we were returning the entire test env name ('functional-pyXY'). There is no Python version corresponding to e.g. 'functional-py39' so this (correctly) fails. We can correct the issue by only returning the factor that modified the base_python value, i.e. the 'pyXY' factor. To ensure we do this, we need some additional logic. It turns out this logic is already present in another helper method on the 'Python' class, 'extract_base_python', so we also take the opportunity to de-duplicate and reuse some logic. Note that this change breaks the ability of users to use a testenv name like 'py38-64' (to get the 64 bit version of a Python 3.8 interpreter). Continuing to support this would require much larger change since we'd no longer be able to strictly delimit factors by hyphens (in this case, the entirety of 'py38-64' becomes a factor). Also note that this change emphasises issue #2657, as this will now be raised for a factor like 'py38-64' since 'tox' (or rather, virtualenv) is falsely identifying '64' as a valid Python interpreter identifier. We will fix this separately so the offending test are skipped for now. Signed-off-by: Stephen Finucane <stephen@that.guru> Fixes: #2838
- Loading branch information