From bc094dd172332d8ed89c8e8b05adec29689138bd Mon Sep 17 00:00:00 2001 From: x12sa Date: Tue, 22 Sep 2026 16:19:45 +0200 Subject: [PATCH] fix(tests): resolve flomni/lamni CLI source paths via module __file__ test_flomni_cli_fovy_bounds_within_scan_bounds and test_lamni_cli_piezo_range_bounds_within_scan_bounds opened the CLI source files using a path hardcoded relative to the repo root, which only works if pytest's cwd happens to equal the repo root. In CI the job's cwd is one level above the checkout, so the same relative path raised FileNotFoundError. Resolve the path from the already-imported module's __file__ instead, which is independent of cwd. Co-Authored-By: Claude Sonnet 5 --- .../test_fov_bounds_match_scan_args.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/tests/tests_bec_ipython_client/test_fov_bounds_match_scan_args.py b/tests/tests_bec_ipython_client/test_fov_bounds_match_scan_args.py index f5074b60..fcc3140f 100644 --- a/tests/tests_bec_ipython_client/test_fov_bounds_match_scan_args.py +++ b/tests/tests_bec_ipython_client/test_fov_bounds_match_scan_args.py @@ -18,6 +18,8 @@ strictly inside them -- not just checked once by hand -- so this class of import re from typing import get_type_hints +import csaxs_bec.bec_ipython_client.plugins.flomni.flomni as _flomni_cli_module +import csaxs_bec.bec_ipython_client.plugins.LamNI.lamni as _lamni_cli_module from csaxs_bec.bec_widgets.widgets.tomo_params.tomo_params import SETUP_PROFILES from csaxs_bec.scans.flomni_fermat_scan import FlomniFermatScan from csaxs_bec.scans.lamni_fermat_scan import LamniFermatScan @@ -62,9 +64,7 @@ def test_flomni_gui_fovx_fovy_within_scan_bounds(): def test_flomni_cli_fovy_bounds_within_scan_bounds(): - src = open( - "csaxs_bec/bec_ipython_client/plugins/flomni/flomni.py", encoding="utf-8" - ).read() + src = open(_flomni_cli_module.__file__, encoding="utf-8").read() m = re.search(r'" um".*?min_=([\d.]+), max_=([\d.]+)', src, re.DOTALL) assert m, "could not find the fovy _get_val() call in flomni.py -- did it move?" cli_min, cli_max = float(m.group(1)), float(m.group(2)) @@ -81,7 +81,7 @@ def test_lamni_gui_piezo_range_within_scan_bounds(): def test_lamni_cli_piezo_range_bounds_within_scan_bounds(): - src = open("csaxs_bec/bec_ipython_client/plugins/LamNI/lamni.py", encoding="utf-8").read() + src = open(_lamni_cli_module.__file__, encoding="utf-8").read() for axis, scan_param in (("X", "fovx"), ("Y", "fovy")): m = re.search( rf'" um".*?min_=([\d.]+), max_=([\d.]+)', src, re.DOTALL