diff --git a/tools/tests/test_native_hook_handoff.py b/tools/tests/test_native_hook_handoff.py index efa66fe81c..544ff43ac0 100644 --- a/tools/tests/test_native_hook_handoff.py +++ b/tools/tests/test_native_hook_handoff.py @@ -780,8 +780,11 @@ class NativeHookHandoffTest(unittest.TestCase): unshare = shutil.which("unshare") if not unshare or subprocess.run([unshare, "-Urpf", "--mount-proc", "true"], capture_output=True).returncode: self.skipTest("no user and pid namespace for this test") + # this module by the name it was loaded as, from the repository's root or this directory + here, top = Path(__file__).resolve().parent, Path(__file__).resolve().parents[2] + path = os.pathsep.join([str(here), str(top)] + ([os.environ["PYTHONPATH"]] if os.environ.get("PYTHONPATH") else [])) out = subprocess.run([unshare, "-Urpf", "--mount-proc", sys.executable, "-m", "unittest", self.id()], - env={**os.environ, "DDH_TEST_PIDNS": "1"}, cwd=Path(__file__).resolve().parents[2], + env={**os.environ, "DDH_TEST_PIDNS": "1", "PYTHONPATH": path}, cwd=top, capture_output=True, text=True, timeout=300) self.assertEqual(0, out.returncode, out.stderr) self.assertNotIn("skipped", out.stderr, out.stderr)