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