Mirko: "the flomni progress bar has three rings. here i am seing only two... at the end of a tomogram in flomni a summary of the measurement time and time lost is displayed. omny seems not to have that, maybe not even measuring the time." Both traced back to the same root gap left by the Phase-1 tomo-queue port: nothing computed estimated_remaining_time/estimated_finish_time, and nothing refreshed progress["heartbeat"] *during* a running scan (only cleared it to None on completion) -- so accumulated_idle_time stayed 0.0 forever and there was no ETA data to show or summarize. - _tomo_scan_at_angle() now refreshes the heartbeat every angle and attributes any gap beyond a normal-cadence heuristic to accumulated_idle_time (mirrors flomni's identical formula, minus its frames_per_trigger factor which OMNY has no property for). - _print_progress() computes/stores/prints estimated_remaining_time and estimated_finish_time once the scan rate has stabilized. - tomo_scan() prints an end-of-scan "Total measurement time"/"...excluding detected gaps"/"...lost to detected gaps" summary and sends it to scilog, direct port of flomni's block (minus its measured_log call, which OMNY has no equivalent of). - gui_tools.py: omnygui_show_progress() adds flomni's third, scan-linked auto-updating ring; _omnygui_update_progress()'s center label now shows start time / ETA / estimated finish / active hook, matching flomni's _flomnigui_update_progress(). _describe_active_hook()/_active_hook_source() needed no porting -- already provided by TomoQueueMixin since Phase 1. Not ported: flomni's separate persistent timing-statistics-log subsystem (_log_tomogram_timing()) -- out of scope for what was actually asked (the printed summary + ring count). 9 new tests (test_omny_tomo_scan.py, test_omny_gui_tools.py). Full suite: 731 passed. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01QLrD7sVYGLAzsQjLVJpCgt
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.