From 98f68d8c34b55c14e32c44d17be228acb17ab8a0 Mon Sep 17 00:00:00 2001 From: Khem Raj Date: Wed, 4 Nov 2026 17:02:19 -0800 Subject: [PATCH] python3-execnet: Fix test_remote_exec_module_is_removed ptest The test is parametrized over gateway types; it imports "remote" from its tmp_path and then deletes that directory, but the module stays in sys.modules. Every run after the first got the stale module back and failed with "OSError: could not get source code". Drop the cached module before importing it. AI-Generated: Uses Claude Code Signed-off-by: Khem Raj --- ...hed-remote-module-in-test_remote_exe.patch | 38 +++++++++++++++++++ .../python/python3-execnet_2.1.2.bb | 2 + 2 files changed, 40 insertions(+) create mode 100644 meta-python/recipes-devtools/python/python3-execnet/0001-testing-Drop-cached-remote-module-in-test_remote_exe.patch diff --git a/meta-python/recipes-devtools/python/python3-execnet/0001-testing-Drop-cached-remote-module-in-test_remote_exe.patch b/meta-python/recipes-devtools/python/python3-execnet/0001-testing-Drop-cached-remote-module-in-test_remote_exe.patch new file mode 100644 index 0000000000..23957588c8 --- /dev/null +++ b/meta-python/recipes-devtools/python/python3-execnet/0001-testing-Drop-cached-remote-module-in-test_remote_exe.patch @@ -0,0 +1,38 @@ +From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 +From: Khem Raj +Date: Wed, 4 Nov 2026 16:22:44 -0800 +Subject: [PATCH] testing: Drop cached remote module in + test_remote_exec_module_is_removed + +test_remote_exec_module_is_removed is parametrized over the gateway +fixtures. The first run imports "remote" from its tmp_path and then +removes that directory, but the module stays in sys.modules. Later +runs then get the stale module back from "import remote", whose source +file is gone, and remote_exec() fails with: + + OSError: could not get source code + +Remove "remote" from sys.modules before importing it, so each run +imports the module it just wrote. + +Upstream-Status: Submitted [https://github.com/pytest-dev/execnet/pull/442] + +Signed-off-by: Khem Raj +--- + testing/test_gateway.py | 3 +++ + 1 file changed, 3 insertions(+) + +diff --git a/testing/test_gateway.py b/testing/test_gateway.py +index 634f237..c571bbd 100644 +--- a/testing/test_gateway.py ++++ b/testing/test_gateway.py +@@ -130,6 +130,9 @@ class TestBasicGateway: + ) + + monkeypatch.syspath_prepend(tmp_path) ++ # The test is parametrized; drop the module cached by a previous run, ++ # whose source file has since been removed. ++ monkeypatch.delitem(sys.modules, "remote", raising=False) + import remote # type: ignore[import-not-found] + + ch = gw.remote_exec(remote) diff --git a/meta-python/recipes-devtools/python/python3-execnet_2.1.2.bb b/meta-python/recipes-devtools/python/python3-execnet_2.1.2.bb index 34f0a1f670..d94ab6375b 100644 --- a/meta-python/recipes-devtools/python/python3-execnet_2.1.2.bb +++ b/meta-python/recipes-devtools/python/python3-execnet_2.1.2.bb @@ -11,6 +11,8 @@ DEPENDS += "\ python3-hatch-vcs-native \ " +SRC_URI += "file://0001-testing-Drop-cached-remote-module-in-test_remote_exe.patch" + SRC_URI[sha256sum] = "63d83bfdd9a23e35b9c6a3261412324f964c2ec8dcd8d3c6916ee9373e0befcd" inherit ptest-python-pytest pypi python_hatchling