Skip to content

Commit 3db9822

Browse files
fix skip with package = wheel (#3269)
* patch `pytest --run-integration` to run with dev versions * fix skip with package = wheel * added sdist test * adjust wheel tests * add docs chanelog news fragment * [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci * fix backticks * [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci * isinstance(_patch_version, str) --------- Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
1 parent 261b4ca commit 3db9822

File tree

4 files changed

+61
-6
lines changed

4 files changed

+61
-6
lines changed

docs/changelog/3269.feature.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Fix ``skip_missing_interpreters`` option for ``package = wheel``

src/tox/tox_env/python/package.py

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -120,7 +120,12 @@ def default_wheel_tag(conf: Config, env_name: str | None) -> str: # noqa: ARG00
120120

121121
def child_pkg_envs(self, run_conf: EnvConfigSet) -> Iterator[PackageToxEnv]:
122122
if run_conf["package"] == "wheel":
123-
env = self._wheel_build_envs.get(run_conf["wheel_build_env"])
123+
try:
124+
conf = run_conf["wheel_build_env"]
125+
except Skip:
126+
# the __getitem__ method might raise Skip if the interpreter is not available
127+
return
128+
env = self._wheel_build_envs.get(conf)
124129
if env is not None and env.name != self.name:
125130
yield env
126131

tests/session/cmd/test_depends.py

Lines changed: 47 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
from tox.pytest import ToxProjectCreator
99

1010

11-
def test_depends(tox_project: ToxProjectCreator, patch_prev_py: Callable[[bool], tuple[str, str]]) -> None:
11+
def test_depends_wheel(tox_project: ToxProjectCreator, patch_prev_py: Callable[[bool], tuple[str, str]]) -> None:
1212
prev_ver, impl = patch_prev_py(True) # has previous python
1313
ver = sys.version_info[0:2]
1414
py = f"py{''.join(str(i) for i in ver)}"
@@ -35,18 +35,61 @@ def test_depends(tox_project: ToxProjectCreator, patch_prev_py: Callable[[bool],
3535
py ~ .pkg
3636
{py} ~ .pkg
3737
{prev_py} ~ .pkg | .pkg-{impl}{prev_ver}
38-
py31 ~ .pkg | ... (could not find python interpreter with spec(s): py31)
38+
py31 ~ .pkg
3939
cov2
4040
cov
4141
py ~ .pkg
4242
{py} ~ .pkg
4343
{prev_py} ~ .pkg | .pkg-{impl}{prev_ver}
44-
py31 ~ .pkg | ... (could not find python interpreter with spec(s): py31)
44+
py31 ~ .pkg
4545
cov
4646
py ~ .pkg
4747
{py} ~ .pkg
4848
{prev_py} ~ .pkg | .pkg-{impl}{prev_ver}
49-
py31 ~ .pkg | ... (could not find python interpreter with spec(s): py31)
49+
py31 ~ .pkg
50+
"""
51+
assert outcome.out == dedent(expected).lstrip()
52+
53+
54+
def test_depends_sdist(tox_project: ToxProjectCreator, patch_prev_py: Callable[[bool], tuple[str, str]]) -> None:
55+
prev_ver, _impl = patch_prev_py(True) # has previous python
56+
ver = sys.version_info[0:2]
57+
py = f"py{''.join(str(i) for i in ver)}"
58+
prev_py = f"py{prev_ver}"
59+
ini = f"""
60+
[tox]
61+
env_list = py,{py},{prev_py},py31,cov2,cov
62+
[testenv]
63+
package = sdist
64+
[testenv:cov]
65+
depends = py,{py},{prev_py},py31
66+
skip_install = true
67+
[testenv:cov2]
68+
depends = cov
69+
skip_install = true
70+
"""
71+
project = tox_project({"tox.ini": ini, "pyproject.toml": ""})
72+
outcome = project.run("de")
73+
outcome.assert_success()
74+
75+
expected = f"""
76+
Execution order: py, {py}, {prev_py}, py31, cov, cov2
77+
ALL
78+
py ~ .pkg
79+
{py} ~ .pkg
80+
{prev_py} ~ .pkg
81+
py31 ~ .pkg
82+
cov2
83+
cov
84+
py ~ .pkg
85+
{py} ~ .pkg
86+
{prev_py} ~ .pkg
87+
py31 ~ .pkg
88+
cov
89+
py ~ .pkg
90+
{py} ~ .pkg
91+
{prev_py} ~ .pkg
92+
py31 ~ .pkg
5093
"""
5194
assert outcome.out == dedent(expected).lstrip()
5295

tests/test_provision.py

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,13 @@ def _make_tox_wheel(
6262
into = tmp_path_factory.mktemp("dist") # pragma: no cover
6363
from tox.version import version_tuple # noqa: PLC0415
6464

65-
version = f"{version_tuple[0]}.{version_tuple[1]}.{int(version_tuple[2]) + 1}"
65+
_patch_version = version_tuple[2]
66+
if isinstance(_patch_version, str) and _patch_version[:3] == "dev":
67+
# Version is in the form of 1.23.dev456, we need to increment the 456 part
68+
version = f"{version_tuple[0]}.{version_tuple[1]}.dev{int(_patch_version[3:]) + 1}"
69+
else:
70+
version = f"{version_tuple[0]}.{version_tuple[1]}.{int(_patch_version) + 1}"
71+
6672
with mock.patch.dict(os.environ, {"SETUPTOOLS_SCM_PRETEND_VERSION": version}):
6773
return pkg_builder(into, Path(__file__).parents[1], ["wheel"], False) # pragma: no cover
6874

0 commit comments

Comments
 (0)