Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2026-09-28 08:27:36

0001 import subprocess
0002 import sys
0003 from pathlib import Path
0004 
0005 
0006 WLS_TEST_SCRIPT = Path(__file__).parents[1] / "ana" / "wls_test.py"
0007 
0008 
0009 def test_package_import_does_not_mutate_sys_path():
0010     code = """
0011 import sys
0012 
0013 before = list(sys.path)
0014 import optiphy.ana.wls_test
0015 assert sys.path == before, f"sys.path mutated: {before!r} -> {sys.path!r}"
0016 """
0017 
0018     result = subprocess.run(
0019         [sys.executable, "-c", code],
0020         capture_output=True,
0021         text=True,
0022     )
0023 
0024     assert result.returncode == 0, result.stderr
0025 
0026 
0027 def test_direct_script_help_remains_supported(tmp_path):
0028     result = subprocess.run(
0029         [sys.executable, str(WLS_TEST_SCRIPT), "--help"],
0030         cwd=tmp_path,
0031         capture_output=True,
0032         text=True,
0033     )
0034 
0035     assert result.returncode == 0, result.stderr
0036     assert "usage:" in result.stdout