summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMichał Górny <mgorny@gentoo.org>2023-08-24 16:30:34 +0200
committerMichał Górny <mgorny@gentoo.org>2023-08-24 16:30:34 +0200
commit10d6110bd40d4407c4bb81db3ff77f8e42163d27 (patch)
treea68d9eb1b1ffd165b704dccc8d7ef59392c50c1e /dev-python/pytest-env
parentmail-mta/postfix: add 3.9_pre20230821, drop 3.9_pre20230808 (diff)
downloadgentoo-10d6110bd40d4407c4bb81db3ff77f8e42163d27.tar.gz
gentoo-10d6110bd40d4407c4bb81db3ff77f8e42163d27.tar.bz2
gentoo-10d6110bd40d4407c4bb81db3ff77f8e42163d27.zip
dev-python/pytest-env: Fix the test suite w/ other plugins
Closes: https://bugs.gentoo.org/908560 Signed-off-by: Michał Górny <mgorny@gentoo.org>
Diffstat (limited to 'dev-python/pytest-env')
-rw-r--r--dev-python/pytest-env/files/pytest-env-1.0.0-test.patch36
-rw-r--r--dev-python/pytest-env/pytest-env-1.0.0.ebuild30
2 files changed, 61 insertions, 5 deletions
diff --git a/dev-python/pytest-env/files/pytest-env-1.0.0-test.patch b/dev-python/pytest-env/files/pytest-env-1.0.0-test.patch
new file mode 100644
index 000000000000..c86815ebc3a2
--- /dev/null
+++ b/dev-python/pytest-env/files/pytest-env-1.0.0-test.patch
@@ -0,0 +1,36 @@
+From 4227409be9a2ca287f227e50fbf4c38ca237b676 Mon Sep 17 00:00:00 2001
+From: =?UTF-8?q?Micha=C5=82=20G=C3=B3rny?= <mgorny@gentoo.org>
+Date: Thu, 24 Aug 2023 06:38:30 +0200
+Subject: [PATCH] Disable plugin autoloading in the test suite
+
+Disable plugin autoloading in the test suite to prevent other installed
+plugins from interfering with the test results. This is particularly
+important since tests are run with cleared environment that could break
+other plugins (e.g. pytest-xvfb is broken by the lack of PATH).
+
+Fixes #48
+---
+ tests/test_env.py | 9 ++++++++-
+ 1 file changed, 8 insertions(+), 1 deletion(-)
+
+diff --git a/tests/test_env.py b/tests/test_env.py
+index 16cd080..a409b60 100644
+--- a/tests/test_env.py
++++ b/tests/test_env.py
+@@ -104,8 +104,15 @@ def test_env(
+ Path(str(tmp_dir / f"test_{test_name}.py")).symlink_to(Path(__file__).parent / "template.py")
+ (tmp_dir / "pytest.ini").write_text(ini, encoding="utf-8")
+
++ new_env = {
++ **env,
++ "_TEST_ENV": repr(expected_env),
++ "PYTEST_DISABLE_PLUGIN_AUTOLOAD": "1",
++ "PYTEST_PLUGINS": "pytest_env.plugin",
++ }
++
+ # monkeypatch persists env variables across parametrized tests, therefore using mock.patch.dict
+- with mock.patch.dict(os.environ, {**env, "_TEST_ENV": repr(expected_env)}, clear=True):
++ with mock.patch.dict(os.environ, new_env, clear=True):
+ result = testdir.runpytest()
+
+ result.assert_outcomes(passed=1)
diff --git a/dev-python/pytest-env/pytest-env-1.0.0.ebuild b/dev-python/pytest-env/pytest-env-1.0.0.ebuild
index db479a2c1572..8f228d09367e 100644
--- a/dev-python/pytest-env/pytest-env-1.0.0.ebuild
+++ b/dev-python/pytest-env/pytest-env-1.0.0.ebuild
@@ -5,17 +5,37 @@ EAPI=8
DISTUTILS_USE_PEP517=hatchling
PYTHON_COMPAT=( python3_{10..12} )
+
inherit distutils-r1 pypi
-DESCRIPTION="py.test plugin that allows you to add environment variables"
-HOMEPAGE="https://github.com/pytest-dev/pytest-env"
+DESCRIPTION="pytest plugin that allows you to add environment variables"
+HOMEPAGE="
+ https://github.com/pytest-dev/pytest-env/
+ https://pypi.org/project/pytest-env/
+"
LICENSE="MIT"
SLOT="0"
KEYWORDS="~amd64 ~arm64 ~hppa ~ppc ~ppc64 ~x86"
-RDEPEND="dev-python/pytest[${PYTHON_USEDEP}]"
-BDEPEND=">=dev-python/hatch-vcs-0.3[${PYTHON_USEDEP}]
- test? ( >=dev-python/pytest-mock-3.10.0[${PYTHON_USEDEP}] )"
+RDEPEND="
+ dev-python/pytest[${PYTHON_USEDEP}]
+"
+BDEPEND="
+ >=dev-python/hatch-vcs-0.3[${PYTHON_USEDEP}]
+ test? (
+ >=dev-python/pytest-mock-3.10.0[${PYTHON_USEDEP}]
+ )
+"
distutils_enable_tests pytest
+
+PATCHES=(
+ # https://github.com/pytest-dev/pytest-env/pull/49
+ "${FILESDIR}/${P}-test.patch"
+)
+
+python_test() {
+ local -x PYTEST_DISABLE_PLUGIN_AUTOLOAD=1
+ epytest
+}