Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions AGENTS.md
Original file line number Diff line number Diff line change
Expand Up @@ -151,6 +151,12 @@ against a fake that encodes what you believe the driver does. They say nothing a
real ranges and units. A passing run is not a hardware validation: never state that a plugin works on an instrument
that was not used, say what was tested on the real device and what only against a fake.

**Testing a Dashboard extension.** `tests/test_plugin_extensions.py` subclasses `PluginExtensionChecks`
(`pymodaq.utils.plugin_testing.extension_testing`, PyMoDAQ >= 5.3.7): every module of `extensions/` that defines
`EXTENSION_NAME` is loaded in an empty Dashboard and closed. For the behaviour of your extension, write tests with the
`loaded_extension(MyExtension)` context manager, which yields `(dashboard, extension)` and closes and deletes the windows
at exit (leaving them alive slows down every test that runs afterwards). Delete the file if the package has no extension.

**Legacy patterns to avoid** (older tutorials and models still produce them; `check_plugin` flags several):
`stage_names` (use `_axis_names`), `_epsilon` (use `_epsilons`), `data_actuator_type = float` (use
`DataActuatorType.DataActuator`), the group names `multiaxes` and `multi_status` (now `controller` and
Expand Down
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ package-url = 'https://github.com/PyMoDAQ/pymodaq_plugins_template' #todo modify
name = "pymodaq_plugins_template" #todo modify template by your plugin short name
description = 'some word about your plugin'
dependencies = [
"pymodaq>=5.3.2",
"pymodaq>=5.3.7",
"pymodaq_utils>=5.3.1",
"pymodaq_gui>=5.3.0",
"pymodaq_data>=5.3.0",
Expand Down
23 changes: 23 additions & 0 deletions tests/test_plugin_extensions.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
"""Tests of the Dashboard extensions of the plugin, provided by PyMoDAQ (from version 5.3.7).

Each extension of the ``extensions`` folder is loaded in an empty Dashboard and closed. Add the tests of the behaviour of
your extensions in this file, with ``loaded_extension`` (from ``pymodaq.utils.plugin_testing``). Delete this file if your
plugin has no extension.
"""
import importlib.util

import pytest

try:
available = importlib.util.find_spec('pymodaq.utils.plugin_testing.extension_testing') is not None
except ModuleNotFoundError: # pymodaq is not installed
available = False
if not available:
pytest.skip('The extension checks need PyMoDAQ >= 5.3.7', allow_module_level=True)

from pymodaq.utils.plugin_testing.extension_testing import PluginExtensionChecks


class TestExtensions(PluginExtensionChecks):
# package_name = 'pymodaq_plugins_xxxx' # only if it cannot be found from the pyproject.toml and the package folder
strict_imports = False # True: an extension that cannot be imported (missing dependency) fails instead of being skipped
Loading