Skip to content

Commit 3528dac

Browse files
committed
Add theme test
1 parent abd00bd commit 3528dac

File tree

4 files changed

+43
-0
lines changed

4 files changed

+43
-0
lines changed
Loading

src/napari_matplotlib/tests/conftest.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import os
2+
from pathlib import Path
23

34
import numpy as np
45
import pytest
@@ -52,3 +53,8 @@ def set_strict_qt():
5253
os.environ[env_var] = old_val
5354
else:
5455
del os.environ[env_var]
56+
57+
58+
@pytest.fixture
59+
def theme_path():
60+
return Path(__file__).parent / "data" / "test_theme.mplstyle"
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
# Dark-theme napari colour scheme for matplotlib plots
2+
3+
#f4b8b2 # light red
4+
#b2e4f4 # light blue
5+
#0aa3fc # dark blue
6+
#008939 # dark green
7+
8+
figure.facecolor : f4b8b2 # light red
9+
axes.facecolor : b2e4f4 # light blue
10+
axes.edgecolor : 0aa3fc # dark blue
11+
12+
xtick.color : 008939 # dark green
13+
xtick.labelcolor : 008939 # dark green
14+
ytick.color : 008939 # dark green
15+
ytick.labelcolor : 008939 # dark green

src/napari_matplotlib/tests/test_theme.py

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
from copy import deepcopy
2+
13
import napari
24
import numpy as np
35
import pytest
@@ -118,3 +120,23 @@ def test_no_theme_side_effects(make_napari_viewer):
118120
unrelated_figure.tight_layout()
119121

120122
return unrelated_figure
123+
124+
125+
@pytest.mark.mpl_image_compare
126+
def test_custom_theme(make_napari_viewer, theme_path, brain_data):
127+
viewer = make_napari_viewer()
128+
viewer.theme = "dark"
129+
130+
widget = ScatterWidget(viewer)
131+
widget.mpl_style_sheet_path = theme_path
132+
133+
viewer.add_image(brain_data[0], **brain_data[1], name="brain")
134+
viewer.add_image(
135+
brain_data[0] * -1, **brain_data[1], name="brain_reversed"
136+
)
137+
138+
viewer.layers.selection.clear()
139+
viewer.layers.selection.add(viewer.layers[0])
140+
viewer.layers.selection.add(viewer.layers[1])
141+
142+
return deepcopy(widget.figure)

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