Skip to content

Commit 0827187

Browse files
authored
Merge pull request #89 from ruaridhg/rugo/figure_tests
First figure test using pytest-mpl
2 parents 1b29dac + 29d3b44 commit 0827187

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
import numpy as np
22
import pytest
3+
from skimage import data
34

45

56
@pytest.fixture(
@@ -11,3 +12,8 @@
1112
)
1213
def image_data(request):
1314
return np.ones(request.param[0]), request.param[1]
15+
16+
17+
@pytest.fixture
18+
def astronaut_data():
19+
return data.astronaut(), {"rgb": True}
Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,12 @@
1+
import pytest
2+
13
from napari_matplotlib import HistogramWidget
24

35

4-
def test_example_q_widget(make_napari_viewer, image_data):
6+
@pytest.mark.mpl_image_compare
7+
def test_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+
return fig

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)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy