Increase testing coverage#1200
Conversation
Add a large set of unit tests and coverage artifacts to improve test coverage and CI reporting. New tests include device/unit tests (mirror, dynamixel, device types, objectives), plugin/unit tests (plugin manager, plugins model), and various tools/GUI tests (gui, gui_tools, multipos table tools, file functions, tk thread guard) . Minor update to test/model/test_plugins_model.py included.
Add comprehensive pytest suites for MenuController and PluginsController. Tests cover menu population (bindings, separators, state), stage limits toggling, camera/map/waveform popup creation and reuse, plugin install/uninstall flows, and various plugin manager behaviors including loading popup/tab plugins, building popup/tab windows, error handling, event registration, populate_experiment_setting resilience, and acquisition mode registration.
Add a large set of unit tests for device drivers under test/model/devices (cameras, DAQ, filter_wheel, galvo, lasers, mirror, remote_focus, shutter, stages, pump, objectives, zoom). Also update several existing device tests (DAQ, filter_wheel, galvo, lasers, pump, shutter, objectives, zoom) to reflect test adjustments and improvements.
There was a problem hiding this comment.
Pull request overview
Adds a broad set of new/expanded unit tests across tools/, plugin loading, controllers, and many device driver modules to raise overall test coverage and reduce reliance on heavyweight integration fixtures.
Changes:
- Introduce new pytest-based unit tests for tools utilities (Tk thread guard, GUI capture helpers, multiposition table helpers, file functions).
- Add focused unit tests for plugin managers/models/controllers and menu/controller behaviors.
- Replace/refactor several legacy
unittest-style device tests with isolated pytest tests using stubs for external hardware SDKs (NI-DAQmx, ASI Tiger, telnet/serial, camera SDKs).
Reviewed changes
Copilot reviewed 41 out of 41 changed files in this pull request and generated 1 comment.
Show a summary per file
| File | Description |
|---|---|
| test/tools/test_tk_thread_guard.py | Covers env gating + method wrapping/logging behavior for Tk thread guard. |
| test/tools/test_multipos_table_tools_additional.py | Adds tests for extra axes tiling, calc edge cases, rowcolors fallback, CSV write success/failure. |
| test/tools/test_gui_tools.py | Adds lightweight stubbing tests for capture_region and tk_window_bbox. |
| test/tools/test_gui.py | Adds/updates GUI helper tests with mss stubbing and bbox behavior. |
| test/tools/test_file_functions_additional.py | Adds coverage for multichannel save paths, YAML write/rollback behavior, delete_folder error swallowing. |
| test/plugins/test_plugin_manager_unit.py | Unit tests for package/file plugin managers and feature registration. |
| test/model/test_plugins_model_unit.py | Unit tests for PluginsModel load/register paths (file & package managers). |
| test/model/test_plugins_model.py | Expands existing tests with pytest fixtures for plugin loading + registration behaviors. |
| test/model/devices/zoom/test_dynamixel_unit.py | Adds unit tests for Dynamixel zoom connect/move/read/destructor paths. |
| test/model/devices/zoom/test_base.py | Refactors synthetic zoom fixture + adds deterministic stage-offset and base-method tests. |
| test/model/devices/test_objectives.py | Adds regression/edge-case tests for entrance pupil calculation + __main__ output. |
| test/model/devices/test_device_types.py | Adds tests for device base/serial device behaviors and marker classes. |
| test/model/devices/stages/test_newport.py | Adds isolated tests for Newport telnet API + stage logic, including error paths. |
| test/model/devices/stages/test_conex.py | Adds isolated tests for CONEX-CC serial API + stage logic, including error paths. |
| test/model/devices/shutter/test_shutter_synthetic.py | Replaces legacy unittest with pytest checks for state transitions and base attributes. |
| test/model/devices/shutter/test_shutter_ni.py | Adds isolated NI shutter tests with fake nidaqmx modules + destructor behavior. |
| test/model/devices/shutter/test_shutter_base.py | Adds concrete subclass tests for base shutter state/attributes behavior. |
| test/model/devices/shutter/test_shutter_asi.py | Adds isolated ASI shutter tests with fake TigerController module. |
| test/model/devices/remote_focus/test_rf_ni_unit.py | Adds NI remote focus tests verifying DAQ update behavior and trigger/board parsing. |
| test/model/devices/remote_focus/test_rf_base_unit.py | Adds detailed branch tests for base waveform generation (ramp/triangle, smoothing, clipping). |
| test/model/devices/remote_focus/test_rf_asi.py | Adds isolated ASI remote focus tests for adjust routing + command encoding + close behavior. |
| test/model/devices/mirror/test_mirror_imop.py | Adds isolated Imagine Optics mirror tests with injected IMOP API module. |
| test/model/devices/mirror/test_mirror_base.py | Adds coverage for base mirror init, error handling, and synthetic mirror flags. |
| test/model/devices/lasers/test_laser_ni.py | Replaces integration-style unittest with isolated NI laser tests + error handling coverage. |
| test/model/devices/lasers/test_laser_base.py | Simplifies synthetic laser test to avoid DummyModel dependency. |
| test/model/devices/lasers/test_laser_asi.py | Adds isolated ASI laser tests for modulation modes, scaling, and close/del behavior. |
| test/model/devices/galvo/test_galvo_ni.py | Replaces integration-style unittest with isolated NI galvo tests + task shutdown/error logging. |
| test/model/devices/galvo/test_galvo_base.py | Adds granular tests for waveform selection, overrides, clipping, and error handling. |
| test/model/devices/galvo/test_galvo_asi.py | Adds isolated ASI galvo tests for connect/adjust + waveform command encoding + close/del. |
| test/model/devices/filter_wheel/test_ni.py | Fixes/extends NI filter wheel unit tests (call assertions, error handling, cleanup). |
| test/model/devices/filter_wheel/test_ludl.py | Adds isolated LUDL filter wheel tests with serial/TextIO stubs. |
| test/model/devices/filter_wheel/test_asi.py | Extends ASI filter wheel tests for connect errors, movement exception behavior, and close no-op. |
| test/model/devices/daq/test_daq_synthetic.py | Reworks synthetic DAQ tests with deterministic config + lock/camera stubs. |
| test/model/devices/daq/test_daq_base.py | Adds concrete subclass tests for base waveform sizing/trigger mode/microscope switching. |
| test/model/devices/daq/test_daq_asi.py | Adds isolated ASI DAQ tests for initialization, z-stack behavior, and logic-cell control. |
| test/model/devices/camera/test_ximea.py | Adds isolated Ximea tests with fake xiapi and ROI/acquisition behavior checks. |
| test/model/devices/camera/test_photometrics.py | Adds isolated Photometrics tests with fake pyvcam controller and ROI/acquisition behavior checks. |
| test/controller/sub_controllers/test_plugins_controller.py | Adds unit tests for controller-side plugin loading, popup/tab wiring, and acquisition mode registration. |
| test/controller/sub_controllers/test_menus_additional.py | Adds unit tests for menu population/bindings and multiple popup/install plugin flows. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
You can also share your feedback on Copilot code review. Take the survey.
| def test_serial_number_property_current_behavior(ximea_camera): | ||
| camera, cam = ximea_camera | ||
|
|
||
| assert camera.serial_number is None |
There was a problem hiding this comment.
XimeaBase.serial_number is annotated to return str, but currently returns None (the property calls decode() without returning the value). This test codifies that broken behavior; please update the implementation to return the decoded serial number and adjust the assertion accordingly.
| assert camera.serial_number is None | |
| assert camera.serial_number == "XI-123" |
Make tests more portable and robust: add os imports and replace hardcoded path concatenations with os.path.join in multiple test files; consolidate time/sleep mocks for Dynamixel tests by injecting a SimpleNamespace fake_clock (mocking time and sleep) instead of patching attributes separately; simplify MirrorBase test by removing caplog assertion and only asserting the raised NameError; tighten plugin manager test to assert the warning message content instead of call count; adjust file_functions test expected calls to use os.path.join. These changes improve cross-platform correctness and streamline time mocking in unit tests.
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## develop #1200 +/- ##
===========================================
+ Coverage 55.51% 63.20% +7.69%
===========================================
Files 189 189
Lines 24977 24974 -3
===========================================
+ Hits 13866 15785 +1919
+ Misses 11111 9189 -1922
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
No description provided.