test(handoff): find the module in the namespace run under discover too

This commit is contained in:
Kurt Himebauch committed 2026-11-28 11:49:19 -05:00
1 parent 61bc8e03b2
commit b1dbfb54da
1 file changed
+4 -1
+4 -1
View File
@@ -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)