summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorStephen Finucane <stephenfinucane@hotmail.com>2023-01-05 18:21:48 +0000
committerGitHub <noreply@github.com>2023-01-05 10:21:48 -0800
commitfc289c06f59b06a0fae0c862d0f2df929f9e182b (patch)
treec4c9c2e0565e13d6940178f2c9fd16761893e61f
parentaf4b5580111b3fec8d9d189861f915081b33c998 (diff)
downloadtox-git-fc289c06f59b06a0fae0c862d0f2df929f9e182b.tar.gz
Fail on mismatched python spec attributes (#2824)
Closes https://github.com/tox-dev/tox/issues/2754
-rw-r--r--docs/changelog/2754.bugfix.rst2
-rw-r--r--src/tox/tox_env/python/api.py2
-rw-r--r--tests/tox_env/python/test_python_api.py1
3 files changed, 4 insertions, 1 deletions
diff --git a/docs/changelog/2754.bugfix.rst b/docs/changelog/2754.bugfix.rst
new file mode 100644
index 00000000..d948067f
--- /dev/null
+++ b/docs/changelog/2754.bugfix.rst
@@ -0,0 +1,2 @@
+Setting ``[testenv] basepython = python3`` will no longer override the Python interpreter version requested by a factor,
+such as ``py311`` - by :user:`stephenfin`.
diff --git a/src/tox/tox_env/python/api.py b/src/tox/tox_env/python/api.py
index 9a8ff6ce..58e73ca2 100644
--- a/src/tox/tox_env/python/api.py
+++ b/src/tox/tox_env/python/api.py
@@ -154,7 +154,7 @@ class Python(ToxEnv, ABC):
if any(
getattr(spec_base, key) != getattr(spec_name, key)
for key in ("implementation", "major", "minor", "micro", "architecture")
- if getattr(spec_base, key) is not None and getattr(spec_name, key) is not None
+ if getattr(spec_name, key) is not None
):
msg = f"env name {env_name} conflicting with base python {base_python}"
if ignore_base_python_conflict:
diff --git a/tests/tox_env/python/test_python_api.py b/tests/tox_env/python/test_python_api.py
index 0520ff17..b11c4376 100644
--- a/tests/tox_env/python/test_python_api.py
+++ b/tests/tox_env/python/test_python_api.py
@@ -95,6 +95,7 @@ def test_base_python_env_no_conflict(env: str, base_python: list[str], ignore_co
("py3", ["py2"], ["py2"]),
("py38", ["py39"], ["py39"]),
("py38", ["py38", "py39"], ["py39"]),
+ ("py38", ["python3"], ["python3"]),
("py310", ["py38", "py39"], ["py38", "py39"]),
("py3.11.1", ["py3.11.2"], ["py3.11.2"]),
("py3-64", ["py3-32"], ["py3-32"]),