diff --git a/AGENTS.md b/AGENTS.md index c6a06a6..9905a4f 100644 --- a/AGENTS.md +++ b/AGENTS.md @@ -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 diff --git a/pyproject.toml b/pyproject.toml index c8de085..30c314e 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -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", diff --git a/tests/test_plugin_extensions.py b/tests/test_plugin_extensions.py new file mode 100644 index 0000000..706ba61 --- /dev/null +++ b/tests/test_plugin_extensions.py @@ -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