From 80477e926823ba8aa647750ed8f9a4e4a4502489 Mon Sep 17 00:00:00 2001 From: Sandro Tosi Date: Thu, 26 Nov 2026 01:51:02 -0500 Subject: [PATCH 1/3] =?UTF-8?q?=F0=9F=A7=AA=20test:=20restore=20inherited?= =?UTF-8?q?=20PYTHONPATH=20in=20native=20env-files=20test?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit #290 made test_native_env_files_override_ini forward the caller's PYTHONPATH to its pytest subprocess; the rewrite in #308 dropped it again, so the subprocess can't import pytest_env.plugin when the plugin is only reachable through PYTHONPATH, and all 24 cases fail. Prepend the caller's PYTHONPATH to the scenario's value; with PYTHONPATH unset the subprocess environment is unchanged. Co-Authored-By: Claude Opus 5.5 --- tests/test_env.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/tests/test_env.py b/tests/test_env.py index 3df9460..ae08c27 100644 --- a/tests/test_env.py +++ b/tests/test_env.py @@ -1163,11 +1163,13 @@ def test_env() -> None: """), ) system_env: Final[dict[str, str]] = {key: os.environ[key] for key in ("SYSTEMROOT", "WINDIR") if key in os.environ} + pythonpath: Final[str] = os.pathsep.join(filter(None, (os.environ.get("PYTHONPATH"), python_env.get("PYTHONPATH")))) mocker.patch.dict( os.environ, { **system_env, **python_env, + **({"PYTHONPATH": pythonpath} if pythonpath else {}), "PYTEST_DISABLE_PLUGIN_AUTOLOAD": "1", "PYTEST_PLUGINS": "pytest_env.plugin", }, From a03cbe30e28bad5c13a8c4045539185d4ff2ace5 Mon Sep 17 00:00:00 2001 From: Sandro Tosi Date: Thu, 26 Nov 2026 02:03:46 -0500 Subject: [PATCH 2/3] =?UTF-8?q?=F0=9F=A7=AA=20test:=20forward=20PYTHONPATH?= =?UTF-8?q?=20without=20a=20conditional?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit simplint's conditional-in-test rule rejects the conditional dict unpacking. Always set PYTHONPATH to the joined value instead: pytester's popen rebuilds PYTHONPATH with filter(None, ...), which drops an empty value, so the case without an inherited PYTHONPATH is unchanged. Co-Authored-By: Claude Opus 5.5 --- tests/test_env.py | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/tests/test_env.py b/tests/test_env.py index ae08c27..17d2b04 100644 --- a/tests/test_env.py +++ b/tests/test_env.py @@ -1163,13 +1163,12 @@ def test_env() -> None: """), ) system_env: Final[dict[str, str]] = {key: os.environ[key] for key in ("SYSTEMROOT", "WINDIR") if key in os.environ} - pythonpath: Final[str] = os.pathsep.join(filter(None, (os.environ.get("PYTHONPATH"), python_env.get("PYTHONPATH")))) mocker.patch.dict( os.environ, { **system_env, **python_env, - **({"PYTHONPATH": pythonpath} if pythonpath else {}), + "PYTHONPATH": os.pathsep.join(filter(None, (os.environ.get("PYTHONPATH"), python_env.get("PYTHONPATH")))), "PYTEST_DISABLE_PLUGIN_AUTOLOAD": "1", "PYTEST_PLUGINS": "pytest_env.plugin", }, From b972310c220bfb23e36c11445cfbd60e0ba27423 Mon Sep 17 00:00:00 2001 From: Sandro Tosi Date: Thu, 26 Nov 2026 02:06:14 -0500 Subject: [PATCH 3/3] =?UTF-8?q?=F0=9F=93=9D=20docs(changelog):=20add=20a?= =?UTF-8?q?=20packaging=20fragment=20for=20the=20PYTHONPATH=20test=20fix?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The news check needs a fragment or the skip news label, which only maintainers can apply. Co-Authored-By: Claude Opus 5.5 --- changelog.d/+native-env-files-pythonpath.packaging.md | 1 + 1 file changed, 1 insertion(+) create mode 100644 changelog.d/+native-env-files-pythonpath.packaging.md diff --git a/changelog.d/+native-env-files-pythonpath.packaging.md b/changelog.d/+native-env-files-pythonpath.packaging.md new file mode 100644 index 0000000..83c4c0f --- /dev/null +++ b/changelog.d/+native-env-files-pythonpath.packaging.md @@ -0,0 +1 @@ +Keep `test_native_env_files_override_ini` passing when packagers run the suite with the plugin only on `PYTHONPATH`.