From 6b2b3cc3a04308d22a11dbfd48ed0ea2c06c822f Mon Sep 17 00:00:00 2001 From: Ziwen Liu <67518483+ziw-liu@users.noreply.github.com> Date: Wed, 7 Jun 2023 15:19:29 -0700 Subject: [PATCH] Test docking the plugin widget (#346) * simple test to dock the plugin widget to a viewer Signed-off-by: Ziwen Liu <67518483+ziw-liu@users.noreply.github.com> * remove python 3.11 support and tests this should be reverted once napari releases with 3.11 support * update gui dependency action * remove more 3.11 reference * update actions according to cookiecutter * delete the widget see https://github.com/napari/napari/issues/3948 * test if the napari viewer fixture works will revert later * Revert "test if the napari viewer fixture works" This reverts commit ccc8dad2de5c0cb4566800dab334010706d42024. * use pytest-xvfb * Revert "delete the widget" This reverts commit 3594e424b2172d5732de66d2d78b97be0f1faa85. * do not import napari * Revert "use pytest-xvfb" This reverts commit a1ce6564d96b81e74f376516a1db84f6eea8b4fd. * skip test for linux CI runners * specify skip reason * comment fixme * explicit boolean condition --------- Signed-off-by: Ziwen Liu <67518483+ziw-liu@users.noreply.github.com> --- .github/workflows/pytests.yml | 2 +- .github/workflows/test_and_deploy.yml | 16 +++++++--------- recOrder/acq/acquisition_workers.py | 1 - recOrder/calib/calibration_workers.py | 1 - recOrder/plugin/main_widget.py | 1 - .../tests/widget_tests/test_dock_widget.py | 18 ++++++++++++++++++ setup.cfg | 1 - tox.ini | 3 +-- 8 files changed, 27 insertions(+), 16 deletions(-) create mode 100644 recOrder/tests/widget_tests/test_dock_widget.py diff --git a/.github/workflows/pytests.yml b/.github/workflows/pytests.yml index b2fd8602..f06ff768 100644 --- a/.github/workflows/pytests.yml +++ b/.github/workflows/pytests.yml @@ -11,7 +11,7 @@ jobs: runs-on: ubuntu-latest strategy: matrix: - python-version: ['3.9', '3.10', '3.11'] + python-version: ['3.9', '3.10'] steps: - name: Checkout repo diff --git a/.github/workflows/test_and_deploy.yml b/.github/workflows/test_and_deploy.yml index 4c037308..e1383631 100644 --- a/.github/workflows/test_and_deploy.yml +++ b/.github/workflows/test_and_deploy.yml @@ -21,13 +21,13 @@ jobs: strategy: matrix: platform: [ubuntu-latest, windows-latest, macos-latest] - python-version: ['3.9', '3.10', '3.11'] + python-version: ['3.9', '3.10'] steps: - - uses: actions/checkout@v2 + - uses: actions/checkout@v3 - name: Set up Python ${{ matrix.python-version }} - uses: actions/setup-python@v2 + uses: actions/setup-python@v4 with: python-version: ${{ matrix.python-version }} @@ -50,16 +50,14 @@ jobs: python -m pip install --upgrade pip python -m pip install setuptools tox tox-gh-actions - # this runs the platform-specific tests declared in tox.ini - - name: Test with tox - uses: GabrielBB/xvfb-action@v1 + # https://github.com/napari/cookiecutter-napari-plugin/commit/cb9a8c152b68473e8beabf44e7ab11fc46483b5d + - name: Test + uses: aganders3/headless-gui@v1 with: run: python -m tox - env: - PLATFORM: ${{ matrix.platform }} - name: Coverage - uses: codecov/codecov-action@v2 + uses: codecov/codecov-action@v3 deploy: # this will run when you have tagged a commit with a version number diff --git a/recOrder/acq/acquisition_workers.py b/recOrder/acq/acquisition_workers.py index 25dd073f..84e84208 100644 --- a/recOrder/acq/acquisition_workers.py +++ b/recOrder/acq/acquisition_workers.py @@ -1,4 +1,3 @@ -# TODO: remove in Python 3.11 from __future__ import annotations from qtpy.QtCore import Signal diff --git a/recOrder/calib/calibration_workers.py b/recOrder/calib/calibration_workers.py index 64d704ea..c3e5dd9c 100644 --- a/recOrder/calib/calibration_workers.py +++ b/recOrder/calib/calibration_workers.py @@ -1,4 +1,3 @@ -# TODO: remove in Python 3.11 from __future__ import annotations from qtpy.QtCore import Signal diff --git a/recOrder/plugin/main_widget.py b/recOrder/plugin/main_widget.py index 985d3b2e..24c58d0b 100644 --- a/recOrder/plugin/main_widget.py +++ b/recOrder/plugin/main_widget.py @@ -1,4 +1,3 @@ -# TODO: remove in Python 3.11 from __future__ import annotations from recOrder.calib.Calibration import QLIPP_Calibration, LC_DEVICE_NAME diff --git a/recOrder/tests/widget_tests/test_dock_widget.py b/recOrder/tests/widget_tests/test_dock_widget.py new file mode 100644 index 00000000..b7f90546 --- /dev/null +++ b/recOrder/tests/widget_tests/test_dock_widget.py @@ -0,0 +1,18 @@ +import sys +import os + +import pytest +from napari.viewer import ViewerModel + +from recOrder.plugin.main_widget import MainWidget + + +# FIXME: Linux Qt platform in GitHub actions +@pytest.mark.skipif( + bool("linux" in sys.platform and os.environ.get("CI")), + reason="Qt on Linux CI runners does not work", +) +def test_dock_widget(make_napari_viewer): + viewer: ViewerModel = make_napari_viewer() + viewer.window.add_dock_widget(MainWidget(viewer)) + assert "recOrder" in list(viewer._window._dock_widgets.keys())[0] diff --git a/setup.cfg b/setup.cfg index 8bf83809..948c8c0a 100644 --- a/setup.cfg +++ b/setup.cfg @@ -13,7 +13,6 @@ classifiers = Programming Language :: Python :: 3 :: Only Programming Language :: Python :: 3.9 Programming Language :: Python :: 3.10 - Programming Language :: Python :: 3.11 Topic :: Scientific/Engineering Topic :: Scientific/Engineering :: Visualization Topic :: Scientific/Engineering :: Information Analysis diff --git a/tox.ini b/tox.ini index 1a4a103f..63675993 100644 --- a/tox.ini +++ b/tox.ini @@ -1,14 +1,13 @@ # Modified from from cookiecutter-napari-plugin # For more information about tox, see https://tox.readthedocs.io/en/latest/ [tox] -envlist = py{39,310,311}-{linux,macos,windows} +envlist = py{39,310}-{linux,macos,windows} isolated_build=true [gh-actions] python = 3.9: py39 3.10: py310 - 3.11: py311 [gh-actions:env] PLATFORM =