Skip to content

Commit

Permalink
fix skip with package = wheel (#3269)
Browse files Browse the repository at this point in the history
* 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>
  • Loading branch information
MarcinKonowalczyk and pre-commit-ci[bot] authored Apr 27, 2024
1 parent 261b4ca commit 3db9822
Show file tree
Hide file tree
Showing 4 changed files with 61 additions and 6 deletions.
1 change: 1 addition & 0 deletions docs/changelog/3269.feature.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Fix ``skip_missing_interpreters`` option for ``package = wheel``
7 changes: 6 additions & 1 deletion src/tox/tox_env/python/package.py
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,12 @@ def default_wheel_tag(conf: Config, env_name: str | None) -> str: # noqa: ARG00

def child_pkg_envs(self, run_conf: EnvConfigSet) -> Iterator[PackageToxEnv]:
if run_conf["package"] == "wheel":
env = self._wheel_build_envs.get(run_conf["wheel_build_env"])
try:
conf = run_conf["wheel_build_env"]
except Skip:
# the __getitem__ method might raise Skip if the interpreter is not available
return
env = self._wheel_build_envs.get(conf)
if env is not None and env.name != self.name:
yield env

Expand Down
51 changes: 47 additions & 4 deletions tests/session/cmd/test_depends.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
from tox.pytest import ToxProjectCreator


def test_depends(tox_project: ToxProjectCreator, patch_prev_py: Callable[[bool], tuple[str, str]]) -> None:
def test_depends_wheel(tox_project: ToxProjectCreator, patch_prev_py: Callable[[bool], tuple[str, str]]) -> None:
prev_ver, impl = patch_prev_py(True) # has previous python
ver = sys.version_info[0:2]
py = f"py{''.join(str(i) for i in ver)}"
Expand All @@ -35,18 +35,61 @@ def test_depends(tox_project: ToxProjectCreator, patch_prev_py: Callable[[bool],
py ~ .pkg
{py} ~ .pkg
{prev_py} ~ .pkg | .pkg-{impl}{prev_ver}
py31 ~ .pkg | ... (could not find python interpreter with spec(s): py31)
py31 ~ .pkg
cov2
cov
py ~ .pkg
{py} ~ .pkg
{prev_py} ~ .pkg | .pkg-{impl}{prev_ver}
py31 ~ .pkg | ... (could not find python interpreter with spec(s): py31)
py31 ~ .pkg
cov
py ~ .pkg
{py} ~ .pkg
{prev_py} ~ .pkg | .pkg-{impl}{prev_ver}
py31 ~ .pkg | ... (could not find python interpreter with spec(s): py31)
py31 ~ .pkg
"""
assert outcome.out == dedent(expected).lstrip()


def test_depends_sdist(tox_project: ToxProjectCreator, patch_prev_py: Callable[[bool], tuple[str, str]]) -> None:
prev_ver, _impl = patch_prev_py(True) # has previous python
ver = sys.version_info[0:2]
py = f"py{''.join(str(i) for i in ver)}"
prev_py = f"py{prev_ver}"
ini = f"""
[tox]
env_list = py,{py},{prev_py},py31,cov2,cov
[testenv]
package = sdist
[testenv:cov]
depends = py,{py},{prev_py},py31
skip_install = true
[testenv:cov2]
depends = cov
skip_install = true
"""
project = tox_project({"tox.ini": ini, "pyproject.toml": ""})
outcome = project.run("de")
outcome.assert_success()

expected = f"""
Execution order: py, {py}, {prev_py}, py31, cov, cov2
ALL
py ~ .pkg
{py} ~ .pkg
{prev_py} ~ .pkg
py31 ~ .pkg
cov2
cov
py ~ .pkg
{py} ~ .pkg
{prev_py} ~ .pkg
py31 ~ .pkg
cov
py ~ .pkg
{py} ~ .pkg
{prev_py} ~ .pkg
py31 ~ .pkg
"""
assert outcome.out == dedent(expected).lstrip()

Expand Down
8 changes: 7 additions & 1 deletion tests/test_provision.py
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,13 @@ def _make_tox_wheel(
into = tmp_path_factory.mktemp("dist") # pragma: no cover
from tox.version import version_tuple # noqa: PLC0415

version = f"{version_tuple[0]}.{version_tuple[1]}.{int(version_tuple[2]) + 1}"
_patch_version = version_tuple[2]
if isinstance(_patch_version, str) and _patch_version[:3] == "dev":
# Version is in the form of 1.23.dev456, we need to increment the 456 part
version = f"{version_tuple[0]}.{version_tuple[1]}.dev{int(_patch_version[3:]) + 1}"
else:
version = f"{version_tuple[0]}.{version_tuple[1]}.{int(_patch_version) + 1}"

with mock.patch.dict(os.environ, {"SETUPTOOLS_SCM_PRETEND_VERSION": version}):
return pkg_builder(into, Path(__file__).parents[1], ["wheel"], False) # pragma: no cover

Expand Down

0 comments on commit 3db9822

Please sign in to comment.