fix(tests): resolve flomni/lamni CLI source paths via module __file__
CI for csaxs_bec / test (pull_request) Successful in 2m57s
Read the Docs Deploy Trigger / trigger-rtd-webhook (push) Successful in 1s
CI for csaxs_bec / test (push) Successful in 2m56s

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 <noreply@anthropic.com>
This commit was merged in pull request #323.
This commit is contained in:
x12saandClaude Sonnet 5 committed 2026-09-22 16:19:45 +02:00
1 parent aeefe5b2de
commit bc094dd172
1 file changed
+4 -4
@@ -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'"<FOV Y \(max 100\)> 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'"<piezo range {axis} \(max 80\)> um".*?min_=([\d.]+), max_=([\d.]+)', src, re.DOTALL