Skip to content

Commit 1cdf213

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

17 files changed

+66
-49
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-49
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,57 @@ 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(
49+
fig.basemap(
6250
region=[0, 9, 0, 9], projection="C3/3/9c", compass="jTL+w4c+d4.5+l"
6351
)
64-
fig_test.basemap(compass="jBR+w5c+d-4.5+l")
65-
66-
return fig_ref, fig_test
52+
fig.basemap(compass="jBR+w5c+d-4.5+l")
53+
return fig
6754

6855

69-
@check_figures_equal()
56+
@pytest.mark.mpl_image_compare
7057
def test_config_font_annot():
7158
"""
72-
Test that setting `FONT_ANNOT` config changes both `FONT_ANNOT_PRIMARY` and
73-
`FONT_ANNOT_SECONDARY`.
59+
Test that setting FONT_ANNOT config changes both FONT_ANNOT_PRIMARY and
60+
FONT_ANNOT_SECONDARY.
7461
"""
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()
62+
fig = Figure()
8163
with config(FONT_ANNOT="6p,red"):
82-
fig_test.basemap(
64+
fig.basemap(
8365
region=[0, 9, 0, 9], projection="C3/3/9c", compass="jTL+w4c+d4.5"
8466
)
85-
fig_test.basemap(compass="jBR+w5c+d-4.5")
86-
87-
return fig_ref, fig_test
67+
fig.basemap(compass="jBR+w5c+d-4.5")
68+
return fig
8869

8970

9071
@pytest.mark.mpl_image_compare
9172
def test_config_format_time_map():
9273
"""
93-
Test that setting `FORMAT_TIME_MAP` config changes both
94-
`FORMAT_TIME_PRIMARY_MAP` and `FORMAT_TIME_SECONDARY_MAP`.
74+
Test that setting FORMAT_TIME_MAP config changes both
75+
FORMAT_TIME_PRIMARY_MAP and FORMAT_TIME_SECONDARY_MAP.
9576
"""
9677
fig = Figure()
9778
with config(FORMAT_TIME_MAP="abbreviation"):
@@ -107,8 +88,8 @@ def test_config_format_time_map():
10788
@pytest.mark.mpl_image_compare
10889
def test_config_map_annot_offset():
10990
"""
110-
Test that setting `MAP_ANNOT_OFFSET` config changes both
111-
`MAP_ANNOT_OFFSET_PRIMARY` and `MAP_ANNOT_OFFSET_SECONDARY`.
91+
Test that setting MAP_ANNOT_OFFSET config changes both
92+
MAP_ANNOT_OFFSET_PRIMARY and MAP_ANNOT_OFFSET_SECONDARY.
11293
"""
11394
fig = Figure()
11495
with config(MAP_ANNOT_OFFSET="15p"):
@@ -124,8 +105,8 @@ def test_config_map_annot_offset():
124105
@pytest.mark.mpl_image_compare
125106
def test_config_map_grid_cross_size():
126107
"""
127-
Test that setting `MAP_GRID_CROSS_SIZE` config changes both
128-
`MAP_GRID_CROSS_SIZE_PRIMARY` and `MAP_GRID_CROSS_SIZE_SECONDARY`.
108+
Test that setting MAP_GRID_CROSS_SIZE config changes both
109+
MAP_GRID_CROSS_SIZE_PRIMARY and MAP_GRID_CROSS_SIZE_SECONDARY.
129110
"""
130111
fig = Figure()
131112
with config(MAP_GRID_CROSS_SIZE="3p"):
@@ -142,8 +123,8 @@ def test_config_map_grid_cross_size():
142123
@pytest.mark.mpl_image_compare
143124
def test_config_map_grid_pen():
144125
"""
145-
Test that setting `MAP_GRID_PEN` config changes both `MAP_GRID_PEN_PRIMARY`
146-
and `MAP_GRID_PEN_SECONDARY`.
126+
Test that setting MAP_GRID_PEN config changes both MAP_GRID_PEN_PRIMARY
127+
and MAP_GRID_PEN_SECONDARY.
147128
"""
148129
fig = Figure()
149130
with config(MAP_GRID_PEN="thick,red"):
@@ -160,8 +141,8 @@ def test_config_map_grid_pen():
160141
@pytest.mark.mpl_image_compare
161142
def test_config_map_tick_length():
162143
"""
163-
Test that setting `MAP_TICK_LENGTH` config changes both
164-
`MAP_TICK_LENGTH_PRIMARY` and `MAP_TICK_LENGTH_SECONDARY`.
144+
Test that setting MAP_TICK_LENGTH config changes both
145+
MAP_TICK_LENGTH_PRIMARY and MAP_TICK_LENGTH_SECONDARY.
165146
"""
166147
fig = Figure()
167148
with config(MAP_TICK_LENGTH="5p"):
@@ -178,8 +159,8 @@ def test_config_map_tick_length():
178159
@pytest.mark.mpl_image_compare
179160
def test_config_map_tick_pen():
180161
"""
181-
Test that setting `MAP_TICK_PEN` config changes both `MAP_TICK_PEN_PRIMARY`
182-
and `MAP_TICK_PEN_SECONDARY`.
162+
Test that setting MAP_TICK_PEN config changes both MAP_TICK_PEN_PRIMARY
163+
and MAP_TICK_PEN_SECONDARY.
183164
"""
184165
fig = Figure()
185166
with config(MAP_TICK_PEN="thick,red"):

0 commit comments

Comments
 (0)