|
|
157d42c |
From 996ad0a53dac123ac0d16f71147f80ac47cc86fe Mon Sep 17 00:00:00 2001
|
|
|
b0d91f9 |
From: Lumir Balhar <lbalhar@redhat.com>
|
|
|
b0d91f9 |
Date: Tue, 10 Jan 2023 08:34:25 +0100
|
|
|
b0d91f9 |
Subject: [PATCH] fix tests
|
|
|
b0d91f9 |
|
|
|
b0d91f9 |
---
|
|
|
b0d91f9 |
pyproject.toml | 4 ----
|
|
|
b0d91f9 |
src/tox/pytest.py | 16 +++----------
|
|
|
b0d91f9 |
tests/test_provision.py | 53 -----------------------------------------
|
|
|
b0d91f9 |
3 files changed, 3 insertions(+), 70 deletions(-)
|
|
|
b0d91f9 |
|
|
|
b0d91f9 |
diff --git a/pyproject.toml b/pyproject.toml
|
|
|
157d42c |
index e8be85a..ba07bde 100644
|
|
|
b0d91f9 |
--- a/pyproject.toml
|
|
|
b0d91f9 |
+++ b/pyproject.toml
|
|
|
157d42c |
@@ -47,8 +47,6 @@ optional-dependencies.docs = [
|
|
|
b0d91f9 |
]
|
|
|
b0d91f9 |
optional-dependencies.testing = [
|
|
|
b0d91f9 |
"build[virtualenv]>=0.9",
|
|
|
b0d91f9 |
- "covdefaults>=2.2.2",
|
|
|
b0d91f9 |
- "devpi-process>=0.3",
|
|
|
b0d91f9 |
"diff-cover>=7.3",
|
|
|
b0d91f9 |
"distlib>=0.3.6",
|
|
|
b0d91f9 |
"flaky>=3.7",
|
|
|
157d42c |
@@ -56,7 +54,6 @@ optional-dependencies.testing = [
|
|
|
157d42c |
"hatchling>=1.12.2",
|
|
|
b0d91f9 |
"psutil>=5.9.4",
|
|
|
b0d91f9 |
"pytest>=7.2",
|
|
|
b0d91f9 |
- "pytest-cov>=4",
|
|
|
b0d91f9 |
"pytest-mock>=3.10",
|
|
|
b0d91f9 |
"pytest-xdist>=3.1",
|
|
|
b0d91f9 |
"re-assert>=1.1",
|
|
|
157d42c |
@@ -108,7 +105,6 @@ paths.source = [
|
|
|
b0d91f9 |
report.fail_under = 88
|
|
|
b0d91f9 |
report.omit = ["src/tox/config/cli/for_docs.py", "tests/execute/local_subprocess/bad_process.py", "tests/type_check/*"]
|
|
|
b0d91f9 |
run.parallel = true
|
|
|
b0d91f9 |
-run.plugins = ["covdefaults"]
|
|
|
b0d91f9 |
|
|
|
b0d91f9 |
[tool.isort]
|
|
|
b0d91f9 |
known_first_party = ["tox", "tests"]
|
|
|
b0d91f9 |
diff --git a/src/tox/pytest.py b/src/tox/pytest.py
|
|
|
b0d91f9 |
index ae21125..f2f1bfb 100644
|
|
|
b0d91f9 |
--- a/src/tox/pytest.py
|
|
|
b0d91f9 |
+++ b/src/tox/pytest.py
|
|
|
b0d91f9 |
@@ -26,7 +26,6 @@ from _pytest.logging import LogCaptureFixture
|
|
|
b0d91f9 |
from _pytest.monkeypatch import MonkeyPatch
|
|
|
b0d91f9 |
from _pytest.python import Function
|
|
|
b0d91f9 |
from _pytest.tmpdir import TempPathFactory
|
|
|
b0d91f9 |
-from devpi_process import IndexServer
|
|
|
b0d91f9 |
from pytest_mock import MockerFixture
|
|
|
b0d91f9 |
from virtualenv.info import fs_supports_symlink
|
|
|
b0d91f9 |
|
|
|
b0d91f9 |
@@ -286,9 +285,9 @@ class ToxProject:
|
|
|
b0d91f9 |
m.setattr(sys, "argv", [sys.executable, "-m", "tox"] + list(args))
|
|
|
b0d91f9 |
m.setenv("VIRTUALENV_SYMLINK_APP_DATA", "1")
|
|
|
b0d91f9 |
m.setenv("VIRTUALENV_SYMLINKS", "1")
|
|
|
b0d91f9 |
- m.setenv("VIRTUALENV_PIP", "embed")
|
|
|
b0d91f9 |
- m.setenv("VIRTUALENV_WHEEL", "embed")
|
|
|
b0d91f9 |
- m.setenv("VIRTUALENV_SETUPTOOLS", "embed")
|
|
|
b0d91f9 |
+ m.setenv("VIRTUALENV_PIP", "bundle")
|
|
|
b0d91f9 |
+ m.setenv("VIRTUALENV_WHEEL", "bundle")
|
|
|
b0d91f9 |
+ m.setenv("VIRTUALENV_SETUPTOOLS", "bundle")
|
|
|
b0d91f9 |
try:
|
|
|
b0d91f9 |
tox_run(args)
|
|
|
b0d91f9 |
except SystemExit as exception:
|
|
|
b0d91f9 |
@@ -472,15 +471,6 @@ def enable_pypi_server(monkeypatch: MonkeyPatch, url: str | None) -> None:
|
|
|
b0d91f9 |
monkeypatch.setenv("PIP_TIMEOUT", str(2))
|
|
|
b0d91f9 |
|
|
|
b0d91f9 |
|
|
|
b0d91f9 |
-@pytest.fixture(scope="session")
|
|
|
b0d91f9 |
-def pypi_server(tmp_path_factory: TempPathFactory) -> Iterator[IndexServer]:
|
|
|
b0d91f9 |
- # takes around 2.5s
|
|
|
b0d91f9 |
- path = tmp_path_factory.mktemp("pypi")
|
|
|
b0d91f9 |
- with IndexServer(path) as server:
|
|
|
b0d91f9 |
- server.create_index("empty", "volatile=False")
|
|
|
b0d91f9 |
- yield server
|
|
|
b0d91f9 |
-
|
|
|
b0d91f9 |
-
|
|
|
b0d91f9 |
@pytest.fixture(scope="session")
|
|
|
b0d91f9 |
def _invalid_index_fake_port() -> int: # noqa: PT005
|
|
|
b0d91f9 |
with closing(socket.socket(socket.AF_INET, socket.SOCK_STREAM)) as socket_handler:
|
|
|
b0d91f9 |
diff --git a/tests/test_provision.py b/tests/test_provision.py
|
|
|
b0d91f9 |
index c7a7fac..76d0b2c 100644
|
|
|
b0d91f9 |
--- a/tests/test_provision.py
|
|
|
b0d91f9 |
+++ b/tests/test_provision.py
|
|
|
b0d91f9 |
@@ -12,7 +12,6 @@ from unittest import mock
|
|
|
b0d91f9 |
from zipfile import ZipFile
|
|
|
b0d91f9 |
|
|
|
b0d91f9 |
import pytest
|
|
|
b0d91f9 |
-from devpi_process import Index, IndexServer
|
|
|
b0d91f9 |
from filelock import FileLock
|
|
|
b0d91f9 |
from packaging.requirements import Requirement
|
|
|
b0d91f9 |
|
|
|
b0d91f9 |
@@ -93,23 +92,6 @@ def tox_wheels(tox_wheel: Path, tmp_path_factory: TempPathFactory) -> list[Path]
|
|
|
b0d91f9 |
return result
|
|
|
b0d91f9 |
|
|
|
b0d91f9 |
|
|
|
b0d91f9 |
-@pytest.fixture(scope="session")
|
|
|
b0d91f9 |
-def pypi_index_self(pypi_server: IndexServer, tox_wheels: list[Path], demo_pkg_inline_wheel: Path) -> Index:
|
|
|
b0d91f9 |
- with elapsed("start devpi and create index"): # takes around 1s
|
|
|
b0d91f9 |
- self_index = pypi_server.create_index("self", "volatile=False")
|
|
|
b0d91f9 |
- with elapsed("upload tox and its wheels to devpi"): # takes around 3.2s on build
|
|
|
b0d91f9 |
- self_index.upload(*tox_wheels, demo_pkg_inline_wheel)
|
|
|
b0d91f9 |
- return self_index
|
|
|
b0d91f9 |
-
|
|
|
b0d91f9 |
-
|
|
|
b0d91f9 |
-@pytest.fixture()
|
|
|
b0d91f9 |
-def _pypi_index_self(pypi_index_self: Index, monkeypatch: MonkeyPatch) -> None:
|
|
|
b0d91f9 |
- pypi_index_self.use()
|
|
|
b0d91f9 |
- monkeypatch.setenv("PIP_INDEX_URL", pypi_index_self.url)
|
|
|
b0d91f9 |
- monkeypatch.setenv("PIP_RETRIES", str(2))
|
|
|
b0d91f9 |
- monkeypatch.setenv("PIP_TIMEOUT", str(5))
|
|
|
b0d91f9 |
-
|
|
|
b0d91f9 |
-
|
|
|
b0d91f9 |
def test_provision_requires_nok(tox_project: ToxProjectCreator) -> None:
|
|
|
b0d91f9 |
ini = "[tox]\nrequires = pkg-does-not-exist\n setuptools==1\nskipsdist=true\n"
|
|
|
b0d91f9 |
outcome = tox_project({"tox.ini": ini}).run("c", "-e", "py")
|
|
|
b0d91f9 |
@@ -121,42 +103,7 @@ def test_provision_requires_nok(tox_project: ToxProjectCreator) -> None:
|
|
|
b0d91f9 |
regex=True,
|
|
|
b0d91f9 |
)
|
|
|
b0d91f9 |
|
|
|
b0d91f9 |
-
|
|
|
b0d91f9 |
-@pytest.mark.integration()
|
|
|
b0d91f9 |
-@pytest.mark.usefixtures("_pypi_index_self")
|
|
|
b0d91f9 |
-def test_provision_requires_ok(tox_project: ToxProjectCreator, tmp_path: Path) -> None:
|
|
|
b0d91f9 |
- proj = tox_project({"tox.ini": "[tox]\nrequires=demo-pkg-inline\n[testenv]\npackage=skip"})
|
|
|
b0d91f9 |
- log = tmp_path / "out.log"
|
|
|
b0d91f9 |
-
|
|
|
b0d91f9 |
- # initial run
|
|
|
b0d91f9 |
- result_first = proj.run("r", "--result-json", str(log))
|
|
|
b0d91f9 |
- result_first.assert_success()
|
|
|
b0d91f9 |
- prov_msg = (
|
|
|
b0d91f9 |
- f"ROOT: will run in automatically provisioned tox, host {sys.executable} is missing"
|
|
|
b0d91f9 |
- f" [requires (has)]: demo-pkg-inline"
|
|
|
b0d91f9 |
- )
|
|
|
b0d91f9 |
- assert prov_msg in result_first.out
|
|
|
b0d91f9 |
-
|
|
|
b0d91f9 |
- with log.open("rt") as file_handler:
|
|
|
b0d91f9 |
- log_report = json.load(file_handler)
|
|
|
b0d91f9 |
- assert "py" in log_report["testenvs"]
|
|
|
b0d91f9 |
-
|
|
|
b0d91f9 |
- # recreate without recreating the provisioned env
|
|
|
b0d91f9 |
- provision_env = result_first.env_conf(".tox")["env_dir"]
|
|
|
b0d91f9 |
- result_recreate_no_pr = proj.run("r", "--recreate", "--no-recreate-provision")
|
|
|
b0d91f9 |
- result_recreate_no_pr.assert_success()
|
|
|
b0d91f9 |
- assert prov_msg in result_recreate_no_pr.out
|
|
|
b0d91f9 |
- assert f"ROOT: remove tox env folder {provision_env}" not in result_recreate_no_pr.out, result_recreate_no_pr.out
|
|
|
b0d91f9 |
-
|
|
|
b0d91f9 |
- # recreate with recreating the provisioned env
|
|
|
b0d91f9 |
- result_recreate = proj.run("r", "--recreate")
|
|
|
b0d91f9 |
- result_recreate.assert_success()
|
|
|
b0d91f9 |
- assert prov_msg in result_recreate.out
|
|
|
b0d91f9 |
- assert f"ROOT: remove tox env folder {provision_env}" in result_recreate.out, result_recreate.out
|
|
|
b0d91f9 |
-
|
|
|
b0d91f9 |
-
|
|
|
b0d91f9 |
@pytest.mark.integration()
|
|
|
b0d91f9 |
-@pytest.mark.usefixtures("_pypi_index_self")
|
|
|
b0d91f9 |
def test_provision_platform_check(tox_project: ToxProjectCreator) -> None:
|
|
|
b0d91f9 |
ini = "[tox]\nrequires=demo-pkg-inline\n[testenv]\npackage=skip\n[testenv:.tox]\nplatform=wrong_platform"
|
|
|
b0d91f9 |
proj = tox_project({"tox.ini": ini})
|
|
|
b0d91f9 |
--
|
|
|
b0d91f9 |
2.38.1
|
|
|
b0d91f9 |
|