|
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" |
0 commit comments