Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit0827187

Browse files
authored
Merge pull request#89 from ruaridhg/rugo/figure_tests
First figure test using pytest-mpl
2 parents1b29dac +29d3b44 commit0827187

File tree

6 files changed

+16
-4
lines changed

6 files changed

+16
-4
lines changed

‎setup.cfg

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,7 @@ testing =
5656
napari[pyqt5]
5757
pytest
5858
pytest-cov
59+
pytest-mpl
5960
pytest-qt
6061
tox
6162
pytest-xvfb;sys_platform == 'linux'

‎src/napari_matplotlib/base.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,7 @@ def __init__(self, napari_viewer: napari.viewer.Viewer):
4848

4949
self.viewer=napari_viewer
5050
self.canvas=FigureCanvas()
51+
self.canvas.widget=self
5152

5253
self.canvas.figure.patch.set_facecolor("none")
5354
self.canvas.figure.set_layout_engine("constrained")

‎src/napari_matplotlib/tests/conftest.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
importnumpyasnp
22
importpytest
3+
fromskimageimportdata
34

45

56
@pytest.fixture(
@@ -11,3 +12,8 @@
1112
)
1213
defimage_data(request):
1314
returnnp.ones(request.param[0]),request.param[1]
15+
16+
17+
@pytest.fixture
18+
defastronaut_data():
19+
returndata.astronaut(), {"rgb":True}
Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,12 @@
1+
importpytest
2+
13
fromnapari_matplotlibimportHistogramWidget
24

35

4-
deftest_example_q_widget(make_napari_viewer,image_data):
6+
@pytest.mark.mpl_image_compare
7+
deftest_example_q_widget(make_napari_viewer,astronaut_data):
58
# Smoke test adding a histogram widget
69
viewer=make_napari_viewer()
7-
viewer.add_image(image_data[0],**image_data[1])
8-
HistogramWidget(viewer)
10+
viewer.add_image(astronaut_data[0],**astronaut_data[1])
11+
fig=HistogramWidget(viewer).figure
12+
returnfig

‎tox.ini

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,4 +11,4 @@ python =
1111

1212
[testenv]
1313
extras = testing
14-
commands = python -m pytest -v --color=yes --cov=napari_matplotlib --cov-report=xml
14+
commands = python -m pytest --mpl -v --color=yes --cov=napari_matplotlib --cov-report=xml

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp