Update to 4.2.6

This commit is contained in:
Lumir Balhar 2022-12-08 09:56:35 +01:00 committed by Miro Hrončok
commit b0d91f94dd
3 changed files with 222 additions and 18 deletions

163
fix-tests.patch Normal file
View file

@ -0,0 +1,163 @@
From 56aa64d876a298c68057d15b0c89866aebfc0d4c 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 e4735d3..0eeab4f 100644
--- a/pyproject.toml
+++ b/pyproject.toml
@@ -46,8 +46,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",
@@ -55,7 +53,6 @@ optional-dependencies.testing = [
"hatchling>=1.12",
"psutil>=5.9.4",
"pytest>=7.2",
- "pytest-cov>=4",
"pytest-mock>=3.10",
"pytest-xdist>=3.1",
"re-assert>=1.1",
@@ -106,7 +103,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

View file

@ -1,15 +1,17 @@
# Tests are disbaled by default, they require:
# a) tested tox to be installed
# Many tests are enabled by default
%bcond_without tests
# However, some tests are disabled by default, becasue they require:
# a) tested tox to be installed and/or
# b) internet connection
# To test, do the following:
# 1) Build --without tests (the default)
# (e.g. fedpkg mockbuild)
# To run them, do the following:
# 1) Build --without ci_tests (the default) and optionally --without tests
# (e.g. fedpkg mockbuild --without tests)
# 2) Install the built package
# (e.g. mock install ./results_python-tox/.../tox-...rpm)
# 3) Build again --with tests (and internet connection)
# (e.g. fedpkg mockbuild --enable-network --no-clean-all --with tests)
# 3) Build again --with ci_tests (and internet connection)
# (e.g. fedpkg mockbuild --no-clean-all --enable-network --with ci_tests)
# The Fedora CI tests do this.
%bcond_with tests
%bcond_with ci_tests
# Unset -s on python shebang - ensure that extensions installed with pip
# to user locations are seen and properly loaded
@ -17,7 +19,7 @@
%global py3_shebang_flags %(echo %py3_shebang_flags | sed s/s//)
Name: python-tox
Version: 3.28.0
Version: 4.2.6
Release: 1%{?dist}
Summary: Virtualenv-based automation of test activities
@ -25,6 +27,11 @@ License: MIT
URL: https://tox.readthedocs.io/
Source0: %{pypi_source tox}
# Remove dependency on devpi-process and 1 test that cannot work without it.
# Remove coverage-related dependencies.
# Adjust virtualenv environment variables to make it work with our patched virtualenv.
Patch: fix-tests.patch
BuildArch: noarch
BuildRequires: python3-devel
@ -39,9 +46,14 @@ BuildRequires: /usr/bin/python
BuildRequires: libffi-devel
# xdist is not used upstream, but we use it to speed up the %%check
BuildRequires: python3-pytest-xdist
# The tests only work if the tested tox is installed :(
# wheel should be included upstream
# https://github.com/tox-dev/tox/pull/2843
BuildRequires: python3-wheel
%if %{with ci_tests}
# The CI tests only work if the tested tox is installed :(
BuildRequires: tox = %{version}-%{release}
%endif
%endif
%global _description %{expand:
Tox as is a generic virtualenv management and test command line tool you
@ -91,17 +103,17 @@ Obsoletes: python3-tox < 3.24.4-2
%prep
%autosetup -p1 -n tox-%{version}
# In https://github.com/tox-dev/tox/pull/2463 upstream insisted on pinning tomli to >=2.0.1.
# However, it works fine with 1.2.3 we have in Fedora 35+36, so we relax the dependency.
# We rely on the Fedora CI to catch problems.
sed -i 's/tomli>=2.0.1/tomli>=1.2.3/' setup.cfg
# Upstream updates dependencies too aggressively
# see https://github.com/tox-dev/tox/pull/2843#discussion_r1065028356
sed -ri 's/"(packaging|filelock|platformdirs|psutil|diff-cover)>=.*/"\1",/g' pyproject.toml
%generate_buildrequires
export SETUPTOOLS_SCM_PRETEND_VERSION="%{version}"
%pyproject_buildrequires -r %{?with_tests:-x testing}
%build
export SETUPTOOLS_SCM_PRETEND_VERSION="%{version}"
%pyproject_wheel
@ -112,16 +124,45 @@ sed -i 's/tomli>=2.0.1/tomli>=1.2.3/' setup.cfg
%if %{with tests}
%check
%pytest -n auto
# test_verbosity_guess_miss_match and some others need
# existing tox.ini config, reported https://github.com/tox-dev/tox/issues/2839
touch tox.ini
# Skipped tests use internal virtualenv functionality to
# download wheels which does not work with "bundled" version of wheel in
# the Fedora's virtualenv patch.
k="${k-}${k+ and }not test_virtualenv_flipped_settings"
k="${k-}${k+ and }not test_virtualenv_env_ignored_if_set"
k="${k-}${k+ and }not test_virtualenv_env_used_if_not_set"
# The following tests either need internet connection or installed tox
# so we only run them on the CI.
%if %{without ci_tests}
k="${k-}${k+ and }not test_virtualenv_flipped_settings"
k="${k-}${k+ and }not test_virtualenv_env_ignored_if_set"
k="${k-}${k+ and }not test_virtualenv_env_used_if_not_set"
k="${k-}${k+ and }not test_build_wheel_external"
k="${k-}${k+ and }not keyboard_interrupt"
k="${k-}${k+ and }not test_call_as_module"
k="${k-}${k+ and }not test_call_as_exe"
# test_local_execute_* have "\r\n" in outputs for some
# unknown reason, reported: https://github.com/tox-dev/tox/issues/2841
k="${k-}${k+ and }not test_local_execute_basic_pass_show_on_standard_newline_flush"
k="${k-}${k+ and }not test_local_execute_write_a_lot"
%endif
%pytest -v -n auto -k "${k-}" --run-integration
%endif
%files -n tox -f %{pyproject_files}
%{_bindir}/tox
%{_bindir}/tox-quickstart
%changelog
* Tue Jan 3 2023 Lumír Balhar <lbalhar@redhat.com> - 4.2.6-1
- Update to 4.2.6 (rhbz#1914413)
* Sun Dec 18 2022 Miro Hrončok <mhroncok@redhat.com> - 3.28.0-1
- Update to 3.28.0

View file

@ -1 +1 @@
SHA512 (tox-3.28.0.tar.gz) = 15c2b5e8f3220cc5be436d5eb0b460fa06ecb04c639f45d31fba284d23743d754e85dfe72fe6a1945f4e3aa094278911834e85c6d973972a3179c905178dec6e
SHA512 (tox-4.2.6.tar.gz) = 23cd73e079c15083f3505d0a23dfd58a581c416292c335fb774d6317bd93baa0b81551e1fa233495910dcc478a19e08047fdbea598ee579b5cf33555c7bf04be