From c7232b3df6430bc3e39beec696915757af7b039d Mon Sep 17 00:00:00 2001 From: Marc Billow Date: Sat, 4 Jul 2026 16:39:03 -0500 Subject: [PATCH] fix: isolate subprocess PYTHONPATH in import-isolation test to prevent false pass --- tests/test_import_isolation.py | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/tests/test_import_isolation.py b/tests/test_import_isolation.py index 735ed95..d2d6119 100644 --- a/tests/test_import_isolation.py +++ b/tests/test_import_isolation.py @@ -3,6 +3,7 @@ on mqtt_demo/. This copies just those two directories into an empty temp dir and imports every module in them there, so a stray `from mqtt_demo... import ...` fails loudly instead of silently passing because mqtt_demo/ happens to also be on sys.path in-repo.""" +import os import shutil import subprocess import sys @@ -25,9 +26,13 @@ def test_protocol_and_ocf_import_without_mqtt_demo_present(tmp_path): ] script = "\n".join(import_lines) + "\nprint('OK')\n" + env = dict(os.environ) + env["PYTHONPATH"] = str(tmp_path) + result = subprocess.run( [sys.executable, "-c", script], cwd=str(tmp_path), + env=env, capture_output=True, text=True, ) assert result.returncode == 0, (