Skip to content

Commit

Permalink
Test docking the plugin widget (#346)
Browse files Browse the repository at this point in the history
* simple test to dock the plugin widget to a viewer

Signed-off-by: Ziwen Liu <[email protected]>

* 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 napari/napari#3948

* test if the napari viewer fixture works
will revert later

* Revert "test if the napari viewer fixture works"

This reverts commit ccc8dad.

* use pytest-xvfb

* Revert "delete the widget"

This reverts commit 3594e42.

* do not import napari

* Revert "use pytest-xvfb"

This reverts commit a1ce656.

* skip test for linux CI runners

* specify skip reason

* comment fixme

* explicit boolean condition

---------

Signed-off-by: Ziwen Liu <[email protected]>
  • Loading branch information
ziw-liu authored Jun 7, 2023
1 parent 802cc62 commit 6b2b3cc
Show file tree
Hide file tree
Showing 8 changed files with 27 additions and 16 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/pytests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
16 changes: 7 additions & 9 deletions .github/workflows/test_and_deploy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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 }}

Expand All @@ -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
Expand Down
1 change: 0 additions & 1 deletion recOrder/acq/acquisition_workers.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
# TODO: remove in Python 3.11
from __future__ import annotations

from qtpy.QtCore import Signal
Expand Down
1 change: 0 additions & 1 deletion recOrder/calib/calibration_workers.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
# TODO: remove in Python 3.11
from __future__ import annotations

from qtpy.QtCore import Signal
Expand Down
1 change: 0 additions & 1 deletion recOrder/plugin/main_widget.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
# TODO: remove in Python 3.11
from __future__ import annotations

from recOrder.calib.Calibration import QLIPP_Calibration, LC_DEVICE_NAME
Expand Down
18 changes: 18 additions & 0 deletions recOrder/tests/widget_tests/test_dock_widget.py
Original file line number Diff line number Diff line change
@@ -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]
1 change: 0 additions & 1 deletion setup.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
3 changes: 1 addition & 2 deletions tox.ini
Original file line number Diff line number Diff line change
@@ -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 =
Expand Down

0 comments on commit 6b2b3cc

Please sign in to comment.