- tomo_scan_projection() now adds the projection to the reconstruction queue itself (like flomni), so custom at_each_angle hooks and direct calls are reconstructed; _at_each_angle()/MagLamNI no longer do it (no double entry). tomo_alignment_scan() opts out (_reconstruct=False) to keep its previous behaviour -- flomni's alignment projections are queued, LamNI's never were. - write_pdf_report(): branch on tomo_type (a golden-ratio scan reported a stale type-1 count and a hardcoded '8 sub-tomograms'), e-account from bec.active_account, tolerate a missing detector_distance. - tomo_parameters_cli(): range guards (stitch 0-50, frames 1-100, >= 8 projections, type-3 >= 1, golden max 0-1e6, bunch size 20-100). - Webpage: projection count for tomo type 1 used flomni's 180-degree sub-tomograms (half the real count); TOMO_TYPES gets a base_angle. Also show the piezo range, manual shift and 0-degree reference rows. - Tomo-params GUI: manual shift is mm end to end (label/range said um, +-1000); golden bunch size floor 20 for LamNI (setter/CLI already required it, so a smaller GUI value broke tomo_queue_execute). flomni fields untouched. - lfzp_info() and the queue 'move Energy' entry used the legacy 'mokev' device (only in device_configs/legacy); now ccm_energy. - Special-angle UnboundLocalError fixed in flomni too (list consumed only after a successful projection, so retries still see the special angle). - Tomo type 3: exact integer sub-tomogram numbering (float truncation mislabelled the boundary projection for ~35 values of n < 400). - XrayEyeAlign.align(): always reset the GUI (DAP forwarding, crosshair) on any failure; xrayeye_update_frame() warns when beamline states are invalid. - Stale text / debug print; gap doc updated with the current status. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
Getting Started with Testing using pytest
BEC is using the pytest framework. It can be installed via
pip install pytest
in your python environment.
We note that pytest is part of the optional-dependencies [dev] of the plugin package.
Introduction
Tests in this package should be stored in the tests directory.
We suggest to sort tests of different submodules, i.e. scans or devices in the respective folder structure, and to folow a naming convention of <test_module_name.py>.
It is mandatory for test files to begin with test_ for pytest to discover them.
To run all tests, navigate to the directory of the plugin from the command line, and run the command
pytest -v --random-order ./tests
Note, the python environment needs to be active.
The additional arg -v allows pytest to run in verbose mode which provides more detailed information about the tests being run.
The argument --random-order instructs pytest to run the tests in random order, which is the default in the CI pipelines.
Test examples
Writing tests can be quite specific for the given function. We recommend writing tests as isolated as possible, i.e. try to test single functions instead of full classes. A very useful class to enable isolated testing is MagicMock. In addition, we also recommend to take a look at the How-to guides from pytest.