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