Skip to content

Commit d7a48dc

Browse files
committed
trying to write test
1 parent 5d36e59 commit d7a48dc

File tree

10 files changed

+91
-79
lines changed

10 files changed

+91
-79
lines changed

MANIFEST.in

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
include LICENSE
22
include README.md
3+
include requirements.txt
34

45
recursive-exclude * __pycache__
56
recursive-exclude * *.py[co]

dev.requirements.txt

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
black
22
pytest
3+
pytest-qt
34
tox
45
sphinx
56
sphinx-autodoc-typehints
6-
sphinx-rtd-theme
7+
sphinx-rtd-theme

docs/res/loader_module_guide.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ Once you have launched the review process, you will have access to the following
4949
Using these, you can check your labels, correct them, save them and keep track of which slices have been checked or not.
5050

5151

52-
Source code :
52+
Source code
5353
-------------------------------------------------
5454

5555
* :doc:`plugin_loader`
Lines changed: 34 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -1,34 +1,34 @@
1-
from napari_cellseg_annotator import ExampleQWidget, example_magic_widget
2-
import numpy as np
3-
4-
# make_napari_viewer is a pytest fixture that returns a napari viewer object
5-
# capsys is a pytest fixture that captures stdout and stderr output streams
6-
def test_example_q_widget(make_napari_viewer, capsys):
7-
# make viewer and add an image layer using our fixture
8-
viewer = make_napari_viewer()
9-
viewer.add_image(np.random.random((100, 100)))
10-
11-
# create our widget, passing in the viewer
12-
my_widget = ExampleQWidget(viewer)
13-
14-
# call our widget method
15-
my_widget._on_click()
16-
17-
# read captured output and check that it's as we expected
18-
captured = capsys.readouterr()
19-
assert captured.out == "napari has 1 layers\n"
20-
21-
22-
def test_example_magic_widget(make_napari_viewer, capsys):
23-
viewer = make_napari_viewer()
24-
layer = viewer.add_image(np.random.random((100, 100)))
25-
26-
# this time, our widget will be a MagicFactory or FunctionGui instance
27-
my_widget = example_magic_widget()
28-
29-
# if we "call" this object, it'll execute our function
30-
my_widget(viewer.layers[0])
31-
32-
# read captured output and check that it's as we expected
33-
captured = capsys.readouterr()
34-
assert captured.out == f"you have selected {layer}\n"
1+
# from napari_cellseg_annotator import ExampleQWidget, example_magic_widget
2+
# import numpy as np
3+
#
4+
# # make_napari_viewer is a pytest fixture that returns a napari viewer object
5+
# # capsys is a pytest fixture that captures stdout and stderr output streams
6+
# def test_example_q_widget(make_napari_viewer, capsys):
7+
# # make viewer and add an image layer using our fixture
8+
# viewer = make_napari_viewer()
9+
# viewer.add_image(np.random.random((100, 100)))
10+
#
11+
# # create our widget, passing in the viewer
12+
# my_widget = ExampleQWidget(viewer)
13+
#
14+
# # call our widget method
15+
# my_widget._on_click()
16+
#
17+
# # read captured output and check that it's as we expected
18+
# captured = capsys.readouterr()
19+
# assert captured.out == "napari has 1 layers\n"
20+
#
21+
#
22+
# def test_example_magic_widget(make_napari_viewer, capsys):
23+
# viewer = make_napari_viewer()
24+
# layer = viewer.add_image(np.random.random((100, 100)))
25+
#
26+
# # this time, our widget will be a MagicFactory or FunctionGui instance
27+
# my_widget = example_magic_widget()
28+
#
29+
# # if we "call" this object, it'll execute our function
30+
# my_widget(viewer.layers[0])
31+
#
32+
# # read captured output and check that it's as we expected
33+
# captured = capsys.readouterr()
34+
# assert captured.out == f"you have selected {layer}\n"
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
from napari_cellseg_annotator.plugin_loader import Loader
2+
3+
4+
def test_loader(make_napari_viewer) :
5+
viewer = make_napari_viewer()
6+
widget = Loader(viewer)
7+
widget.show_dialog_mod()
Lines changed: 34 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -1,34 +1,34 @@
1-
from napari_cellseg_annotator import ExampleQWidget, example_magic_widget
2-
import numpy as np
3-
4-
# make_napari_viewer is a pytest fixture that returns a napari viewer object
5-
# capsys is a pytest fixture that captures stdout and stderr output streams
6-
def test_example_q_widget(make_napari_viewer, capsys):
7-
# make viewer and add an image layer using our fixture
8-
viewer = make_napari_viewer()
9-
viewer.add_image(np.random.random((100, 100)))
10-
11-
# create our widget, passing in the viewer
12-
my_widget = ExampleQWidget(viewer)
13-
14-
# call our widget method
15-
my_widget._on_click()
16-
17-
# read captured output and check that it's as we expected
18-
captured = capsys.readouterr()
19-
assert captured.out == "napari has 1 layers\n"
20-
21-
22-
def test_example_magic_widget(make_napari_viewer, capsys):
23-
viewer = make_napari_viewer()
24-
layer = viewer.add_image(np.random.random((100, 100)))
25-
26-
# this time, our widget will be a MagicFactory or FunctionGui instance
27-
my_widget = example_magic_widget()
28-
29-
# if we "call" this object, it'll execute our function
30-
my_widget(viewer.layers[0])
31-
32-
# read captured output and check that it's as we expected
33-
captured = capsys.readouterr()
34-
assert captured.out == f"you have selected {layer}\n"
1+
# from napari_cellseg_annotator import ExampleQWidget, example_magic_widget
2+
# import numpy as np
3+
#
4+
# # make_napari_viewer is a pytest fixture that returns a napari viewer object
5+
# # capsys is a pytest fixture that captures stdout and stderr output streams
6+
# def test_example_q_widget(make_napari_viewer, capsys):
7+
# # make viewer and add an image layer using our fixture
8+
# viewer = make_napari_viewer()
9+
# viewer.add_image(np.random.random((100, 100)))
10+
#
11+
# # create our widget, passing in the viewer
12+
# my_widget = ExampleQWidget(viewer)
13+
#
14+
# # call our widget method
15+
# my_widget._on_click()
16+
#
17+
# # read captured output and check that it's as we expected
18+
# captured = capsys.readouterr()
19+
# assert captured.out == "napari has 1 layers\n"
20+
#
21+
#
22+
# def test_example_magic_widget(make_napari_viewer, capsys):
23+
# viewer = make_napari_viewer()
24+
# layer = viewer.add_image(np.random.random((100, 100)))
25+
#
26+
# # this time, our widget will be a MagicFactory or FunctionGui instance
27+
# my_widget = example_magic_widget()
28+
#
29+
# # if we "call" this object, it'll execute our function
30+
# my_widget(viewer.layers[0])
31+
#
32+
# # read captured output and check that it's as we expected
33+
# captured = capsys.readouterr()
34+
# assert captured.out == f"you have selected {layer}\n"

napari_cellseg_annotator/conftest.py

Whitespace-only changes.

napari_cellseg_annotator/napari.yaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ schema_version: 0.0.1
55
contributions:
66
commands:
77
- id: napari-cellseg-annotator.load
8-
title: Create Loader
8+
title: Create review loader
99
python_name: napari_cellseg_annotator.plugins:Loader
1010

1111
# - id: napari-cellseg-annotator.train
@@ -20,7 +20,7 @@ contributions:
2020
python_name: napari_cellseg_annotator.plugins:Helper
2121
widgets:
2222
- command: napari-cellseg-annotator.load
23-
display_name: Loader
23+
display_name: Review loader
2424

2525
# - command: napari-cellseg-annotator.train
2626
# display_name: Trainer

napari_cellseg_annotator/plugin_loader.py

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@
99
QPushButton,
1010
QSizePolicy,
1111
QLabel,
12-
QFileDialog,
1312
QComboBox,
1413
QLineEdit,
1514
QCheckBox,
@@ -44,15 +43,15 @@ class Loader(QWidget):
4443
def __init__(self, viewer: "napari.viewer.Viewer", parent=None):
4544
"""Creates a Loader plugin with several buttons :
4645
47-
Open file prompt to select volumes directory
46+
* Open file prompt to select volumes directory
4847
49-
Open file prompt to select labels directory
48+
* Open file prompt to select labels directory
5049
51-
A dropdown menu with a choice of png or tif filetypes
50+
* A dropdown menu with a choice of png or tif filetypes
5251
53-
A checkbox if you want to create a new status csv for the dataset
52+
* A checkbox if you want to create a new status csv for the dataset
5453
55-
A button to launch the review process (see :doc:`launch_review`)
54+
* A button to launch the review process (see :doc:`launch_review`)
5655
"""
5756

5857
super().__init__(parent)

tox.ini

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,11 +22,13 @@ platform =
2222
windows: win32
2323
passenv =
2424
CI
25+
PYTHONPATH
2526
GITHUB_ACTIONS
2627
DISPLAY XAUTHORITY
2728
NUMPY_EXPERIMENTAL_ARRAY_FUNCTION
2829
PYVISTA_OFF_SCREEN
29-
deps =
30+
deps =
31+
; -r{toxinidir}\requirements.txt
3032
pytest # https://docs.pytest.org/en/latest/contents.html
3133
pytest-cov # https://pytest-cov.readthedocs.io/en/latest/
3234
# you can remove these if you don't use them
@@ -35,4 +37,6 @@ deps =
3537
pytest-qt
3638
qtpy
3739
pyqt5
40+
opencv-python
41+
3842
commands = pytest -v --color=yes --cov=napari_cellseg_annotator --cov-report=xml

0 commit comments

Comments
 (0)