Skip to content

Commit 8cfebe0

Browse files
committed
Migrate pygmt.config tests to dvc
1 parent c05c975 commit 8cfebe0

17 files changed

+66
-53
lines changed

pygmt/tests/baseline/test_config.png

-50.9 KB
Binary file not shown.
+4
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
outs:
2+
- md5: 7ce85985adb3858a2f8abc78e6f2826b
3+
size: 52132
4+
path: test_config.png
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
outs:
2+
- md5: e1a3887151ea389de97f177c19488c5e
3+
size: 80854
4+
path: test_config_font_annot.png
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
outs:
2+
- md5: b011328f9e88799e3af073da4f2b3835
3+
size: 97085
4+
path: test_config_font_one.png
Binary file not shown.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
outs:
2+
- md5: 3d1d843c5150f2f775fdb9382284fa31
3+
size: 10906
4+
path: test_config_format_time_map.png
Binary file not shown.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
outs:
2+
- md5: 40a89f9014ac054f5f196ace06a00361
3+
size: 9389
4+
path: test_config_map_annot_offset.png
Binary file not shown.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
outs:
2+
- md5: cedcf979e9d25129babae0fbeeeecfbc
3+
size: 17539
4+
path: test_config_map_grid_cross_size.png
-16.8 KB
Binary file not shown.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
outs:
2+
- md5: 04de12d91ce2f48ad0b09061077f9780
3+
size: 17179
4+
path: test_config_map_grid_pen.png
Binary file not shown.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
outs:
2+
- md5: d97081684520b6a91221d25f71942cc9
3+
size: 16855
4+
path: test_config_map_tick_length.png
-16.9 KB
Binary file not shown.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
outs:
2+
- md5: 95a1755035175e331efc7508d9e8e3eb
3+
size: 17321
4+
path: test_config_map_tick_pen.png

pygmt/tests/test_config.py

+30-53
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,8 @@
11
"""
2-
Tests for gmt config.
2+
Tests for pygmt.config.
33
"""
44
import pytest
55
from pygmt import Figure, config
6-
from pygmt.helpers.testing import check_figures_equal
76

87

98
@pytest.mark.mpl_image_compare
@@ -23,75 +22,53 @@ def test_config():
2322
region="0/10/0/10",
2423
projection="X10c/10c",
2524
frame=['xaf+l"red label"', "yaf", '+t"red annotation"'],
26-
X="15c",
25+
xshift="15c",
2726
)
2827

2928
fig.basemap(
3029
region="0/10/0/10",
3130
projection="X10c/10c",
3231
frame=["af", '+t"Blue Annotation"'],
33-
X="15c",
32+
xshift="15c",
3433
)
3534
# Revert to default settings in current figure
3635
config(FONT_ANNOT_PRIMARY="black")
3736
return fig
3837

3938

40-
@check_figures_equal()
39+
@pytest.mark.mpl_image_compare
4140
def test_config_font_one():
4241
"""
43-
Test that setting `FONT` config changes all `FONT_*` settings except
44-
`FONT_LOGO`.
42+
Test that setting FONT config changes all FONT_* settings except FONT_LOGO.
4543
46-
Specifically, this test only checks that `FONT_ANNOT_PRIMARY`,
47-
`FONT_ANNOT_SECONDARY`, `FONT_LABEL`, and `FONT_TITLE` are modified.
44+
Specifically, this test only checks that FONT_ANNOT_PRIMARY,
45+
FONT_ANNOT_SECONDARY, FONT_LABEL, and FONT_TITLE are modified.
4846
"""
49-
fig_ref = Figure()
50-
with config(
51-
FONT_ANNOT_PRIMARY="8p,red",
52-
FONT_ANNOT_SECONDARY="8p,red",
53-
FONT_LABEL="8p,red",
54-
FONT_TITLE="8p,red",
55-
):
56-
fig_ref.basemap(R="0/9/0/9", J="C3/3/9c", Tm="jTL+w4c+d4.5+l")
57-
fig_ref.basemap(Tm="jBR+w5c+d-4.5+l")
58-
59-
fig_test = Figure()
47+
fig = Figure()
6048
with config(FONT="8p,red"):
61-
fig_test.basemap(
62-
region=[0, 9, 0, 9], projection="C3/3/9c", compass="jTL+w4c+d4.5+l"
63-
)
64-
fig_test.basemap(compass="jBR+w5c+d-4.5+l")
65-
66-
return fig_ref, fig_test
49+
fig.basemap(region=[0, 9, 0, 9], projection="C3/3/9c", compass="jTL+w4c+d4.5+l")
50+
fig.basemap(compass="jBR+w5c+d-4.5+l")
51+
return fig
6752

6853

69-
@check_figures_equal()
54+
@pytest.mark.mpl_image_compare
7055
def test_config_font_annot():
7156
"""
72-
Test that setting `FONT_ANNOT` config changes both `FONT_ANNOT_PRIMARY` and
73-
`FONT_ANNOT_SECONDARY`.
57+
Test that setting FONT_ANNOT config changes both FONT_ANNOT_PRIMARY and
58+
FONT_ANNOT_SECONDARY.
7459
"""
75-
fig_ref = Figure()
76-
with config(FONT_ANNOT_PRIMARY="6p,red", FONT_ANNOT_SECONDARY="6p,red"):
77-
fig_ref.basemap(R="0/9/0/9", J="C3/3/9c", Tm="jTL+w4c+d4.5")
78-
fig_ref.basemap(compass="jBR+w5c+d-4.5")
79-
80-
fig_test = Figure()
60+
fig = Figure()
8161
with config(FONT_ANNOT="6p,red"):
82-
fig_test.basemap(
83-
region=[0, 9, 0, 9], projection="C3/3/9c", compass="jTL+w4c+d4.5"
84-
)
85-
fig_test.basemap(compass="jBR+w5c+d-4.5")
86-
87-
return fig_ref, fig_test
62+
fig.basemap(region=[0, 9, 0, 9], projection="C3/3/9c", compass="jTL+w4c+d4.5")
63+
fig.basemap(compass="jBR+w5c+d-4.5")
64+
return fig
8865

8966

9067
@pytest.mark.mpl_image_compare
9168
def test_config_format_time_map():
9269
"""
93-
Test that setting `FORMAT_TIME_MAP` config changes both
94-
`FORMAT_TIME_PRIMARY_MAP` and `FORMAT_TIME_SECONDARY_MAP`.
70+
Test that setting FORMAT_TIME_MAP config changes both
71+
FORMAT_TIME_PRIMARY_MAP and FORMAT_TIME_SECONDARY_MAP.
9572
"""
9673
fig = Figure()
9774
with config(FORMAT_TIME_MAP="abbreviation"):
@@ -107,8 +84,8 @@ def test_config_format_time_map():
10784
@pytest.mark.mpl_image_compare
10885
def test_config_map_annot_offset():
10986
"""
110-
Test that setting `MAP_ANNOT_OFFSET` config changes both
111-
`MAP_ANNOT_OFFSET_PRIMARY` and `MAP_ANNOT_OFFSET_SECONDARY`.
87+
Test that setting MAP_ANNOT_OFFSET config changes both
88+
MAP_ANNOT_OFFSET_PRIMARY and MAP_ANNOT_OFFSET_SECONDARY.
11289
"""
11390
fig = Figure()
11491
with config(MAP_ANNOT_OFFSET="15p"):
@@ -124,8 +101,8 @@ def test_config_map_annot_offset():
124101
@pytest.mark.mpl_image_compare
125102
def test_config_map_grid_cross_size():
126103
"""
127-
Test that setting `MAP_GRID_CROSS_SIZE` config changes both
128-
`MAP_GRID_CROSS_SIZE_PRIMARY` and `MAP_GRID_CROSS_SIZE_SECONDARY`.
104+
Test that setting MAP_GRID_CROSS_SIZE config changes both
105+
MAP_GRID_CROSS_SIZE_PRIMARY and MAP_GRID_CROSS_SIZE_SECONDARY.
129106
"""
130107
fig = Figure()
131108
with config(MAP_GRID_CROSS_SIZE="3p"):
@@ -142,8 +119,8 @@ def test_config_map_grid_cross_size():
142119
@pytest.mark.mpl_image_compare
143120
def test_config_map_grid_pen():
144121
"""
145-
Test that setting `MAP_GRID_PEN` config changes both `MAP_GRID_PEN_PRIMARY`
146-
and `MAP_GRID_PEN_SECONDARY`.
122+
Test that setting MAP_GRID_PEN config changes both MAP_GRID_PEN_PRIMARY and
123+
MAP_GRID_PEN_SECONDARY.
147124
"""
148125
fig = Figure()
149126
with config(MAP_GRID_PEN="thick,red"):
@@ -160,8 +137,8 @@ def test_config_map_grid_pen():
160137
@pytest.mark.mpl_image_compare
161138
def test_config_map_tick_length():
162139
"""
163-
Test that setting `MAP_TICK_LENGTH` config changes both
164-
`MAP_TICK_LENGTH_PRIMARY` and `MAP_TICK_LENGTH_SECONDARY`.
140+
Test that setting MAP_TICK_LENGTH config changes both
141+
MAP_TICK_LENGTH_PRIMARY and MAP_TICK_LENGTH_SECONDARY.
165142
"""
166143
fig = Figure()
167144
with config(MAP_TICK_LENGTH="5p"):
@@ -178,8 +155,8 @@ def test_config_map_tick_length():
178155
@pytest.mark.mpl_image_compare
179156
def test_config_map_tick_pen():
180157
"""
181-
Test that setting `MAP_TICK_PEN` config changes both `MAP_TICK_PEN_PRIMARY`
182-
and `MAP_TICK_PEN_SECONDARY`.
158+
Test that setting MAP_TICK_PEN config changes both MAP_TICK_PEN_PRIMARY and
159+
MAP_TICK_PEN_SECONDARY.
183160
"""
184161
fig = Figure()
185162
with config(MAP_TICK_PEN="thick,red"):

0 commit comments

Comments
 (0)