diff --git a/pygmt/tests/baseline/test_config.png b/pygmt/tests/baseline/test_config.png deleted file mode 100644 index d234eb2684c..00000000000 Binary files a/pygmt/tests/baseline/test_config.png and /dev/null differ diff --git a/pygmt/tests/baseline/test_config.png.dvc b/pygmt/tests/baseline/test_config.png.dvc new file mode 100644 index 00000000000..15ec2a7f978 --- /dev/null +++ b/pygmt/tests/baseline/test_config.png.dvc @@ -0,0 +1,4 @@ +outs: +- md5: e473079025646ea07e44493f6ab396da + size: 33464 + path: test_config.png diff --git a/pygmt/tests/baseline/test_config_font_annot.png.dvc b/pygmt/tests/baseline/test_config_font_annot.png.dvc new file mode 100644 index 00000000000..c62c46e4c4f --- /dev/null +++ b/pygmt/tests/baseline/test_config_font_annot.png.dvc @@ -0,0 +1,4 @@ +outs: +- md5: e1a3887151ea389de97f177c19488c5e + size: 80854 + path: test_config_font_annot.png diff --git a/pygmt/tests/baseline/test_config_font_one.png.dvc b/pygmt/tests/baseline/test_config_font_one.png.dvc new file mode 100644 index 00000000000..4e5bff0ae29 --- /dev/null +++ b/pygmt/tests/baseline/test_config_font_one.png.dvc @@ -0,0 +1,4 @@ +outs: +- md5: b011328f9e88799e3af073da4f2b3835 + size: 97085 + path: test_config_font_one.png diff --git a/pygmt/tests/baseline/test_config_format_time_map.png b/pygmt/tests/baseline/test_config_format_time_map.png deleted file mode 100644 index 0b96d80fdb4..00000000000 Binary files a/pygmt/tests/baseline/test_config_format_time_map.png and /dev/null differ diff --git a/pygmt/tests/baseline/test_config_format_time_map.png.dvc b/pygmt/tests/baseline/test_config_format_time_map.png.dvc new file mode 100644 index 00000000000..ea3697f8c91 --- /dev/null +++ b/pygmt/tests/baseline/test_config_format_time_map.png.dvc @@ -0,0 +1,4 @@ +outs: +- md5: 3d1d843c5150f2f775fdb9382284fa31 + size: 10906 + path: test_config_format_time_map.png diff --git a/pygmt/tests/baseline/test_config_map_annot_offset.png b/pygmt/tests/baseline/test_config_map_annot_offset.png deleted file mode 100644 index 71cb475d5af..00000000000 Binary files a/pygmt/tests/baseline/test_config_map_annot_offset.png and /dev/null differ diff --git a/pygmt/tests/baseline/test_config_map_annot_offset.png.dvc b/pygmt/tests/baseline/test_config_map_annot_offset.png.dvc new file mode 100644 index 00000000000..463e464af5b --- /dev/null +++ b/pygmt/tests/baseline/test_config_map_annot_offset.png.dvc @@ -0,0 +1,4 @@ +outs: +- md5: 40a89f9014ac054f5f196ace06a00361 + size: 9389 + path: test_config_map_annot_offset.png diff --git a/pygmt/tests/baseline/test_config_map_grid_cross_size.png b/pygmt/tests/baseline/test_config_map_grid_cross_size.png deleted file mode 100644 index 2f4d1425721..00000000000 Binary files a/pygmt/tests/baseline/test_config_map_grid_cross_size.png and /dev/null differ diff --git a/pygmt/tests/baseline/test_config_map_grid_cross_size.png.dvc b/pygmt/tests/baseline/test_config_map_grid_cross_size.png.dvc new file mode 100644 index 00000000000..1d8e10c2b7b --- /dev/null +++ b/pygmt/tests/baseline/test_config_map_grid_cross_size.png.dvc @@ -0,0 +1,4 @@ +outs: +- md5: cedcf979e9d25129babae0fbeeeecfbc + size: 17539 + path: test_config_map_grid_cross_size.png diff --git a/pygmt/tests/baseline/test_config_map_grid_pen.png b/pygmt/tests/baseline/test_config_map_grid_pen.png deleted file mode 100644 index 31cd1d84bcd..00000000000 Binary files a/pygmt/tests/baseline/test_config_map_grid_pen.png and /dev/null differ diff --git a/pygmt/tests/baseline/test_config_map_grid_pen.png.dvc b/pygmt/tests/baseline/test_config_map_grid_pen.png.dvc new file mode 100644 index 00000000000..63346fe15ca --- /dev/null +++ b/pygmt/tests/baseline/test_config_map_grid_pen.png.dvc @@ -0,0 +1,4 @@ +outs: +- md5: 04de12d91ce2f48ad0b09061077f9780 + size: 17179 + path: test_config_map_grid_pen.png diff --git a/pygmt/tests/baseline/test_config_map_tick_length.png b/pygmt/tests/baseline/test_config_map_tick_length.png deleted file mode 100644 index 5a795cd646a..00000000000 Binary files a/pygmt/tests/baseline/test_config_map_tick_length.png and /dev/null differ diff --git a/pygmt/tests/baseline/test_config_map_tick_length.png.dvc b/pygmt/tests/baseline/test_config_map_tick_length.png.dvc new file mode 100644 index 00000000000..9374477d852 --- /dev/null +++ b/pygmt/tests/baseline/test_config_map_tick_length.png.dvc @@ -0,0 +1,4 @@ +outs: +- md5: d97081684520b6a91221d25f71942cc9 + size: 16855 + path: test_config_map_tick_length.png diff --git a/pygmt/tests/baseline/test_config_map_tick_pen.png b/pygmt/tests/baseline/test_config_map_tick_pen.png deleted file mode 100644 index 305ee595f81..00000000000 Binary files a/pygmt/tests/baseline/test_config_map_tick_pen.png and /dev/null differ diff --git a/pygmt/tests/baseline/test_config_map_tick_pen.png.dvc b/pygmt/tests/baseline/test_config_map_tick_pen.png.dvc new file mode 100644 index 00000000000..3395c80075b --- /dev/null +++ b/pygmt/tests/baseline/test_config_map_tick_pen.png.dvc @@ -0,0 +1,4 @@ +outs: +- md5: 95a1755035175e331efc7508d9e8e3eb + size: 17321 + path: test_config_map_tick_pen.png diff --git a/pygmt/tests/test_config.py b/pygmt/tests/test_config.py index 63a3005d918..ba39ab53b79 100644 --- a/pygmt/tests/test_config.py +++ b/pygmt/tests/test_config.py @@ -1,9 +1,8 @@ """ -Tests for gmt config. +Tests for pygmt.config. """ import pytest from pygmt import Figure, config -from pygmt.helpers.testing import check_figures_equal @pytest.mark.mpl_image_compare @@ -15,83 +14,61 @@ def test_config(): # Change global settings of current figure config(FONT_ANNOT_PRIMARY="blue") fig.basemap( - region="0/10/0/10", projection="X10c/10c", frame=["af", '+t"Blue Annotation"'] + region=[0, 10, 0, 10], projection="X5c/5c", frame=["af", '+t"Blue Annotation"'] ) with config(FONT_LABEL="red", FONT_ANNOT_PRIMARY="red"): fig.basemap( - region="0/10/0/10", - projection="X10c/10c", + region=[0, 10, 0, 10], + projection="X5c/5c", frame=['xaf+l"red label"', "yaf", '+t"red annotation"'], - X="15c", + xshift="7c", ) fig.basemap( - region="0/10/0/10", - projection="X10c/10c", + region=[0, 10, 0, 10], + projection="X5c/5c", frame=["af", '+t"Blue Annotation"'], - X="15c", + xshift="7c", ) # Revert to default settings in current figure config(FONT_ANNOT_PRIMARY="black") return fig -@check_figures_equal() +@pytest.mark.mpl_image_compare def test_config_font_one(): """ - Test that setting `FONT` config changes all `FONT_*` settings except - `FONT_LOGO`. + Test that setting FONT config changes all FONT_* settings except FONT_LOGO. - Specifically, this test only checks that `FONT_ANNOT_PRIMARY`, - `FONT_ANNOT_SECONDARY`, `FONT_LABEL`, and `FONT_TITLE` are modified. + Specifically, this test only checks that FONT_ANNOT_PRIMARY, + FONT_ANNOT_SECONDARY, FONT_LABEL, and FONT_TITLE are modified. """ - fig_ref = Figure() - with config( - FONT_ANNOT_PRIMARY="8p,red", - FONT_ANNOT_SECONDARY="8p,red", - FONT_LABEL="8p,red", - FONT_TITLE="8p,red", - ): - fig_ref.basemap(R="0/9/0/9", J="C3/3/9c", Tm="jTL+w4c+d4.5+l") - fig_ref.basemap(Tm="jBR+w5c+d-4.5+l") - - fig_test = Figure() + fig = Figure() with config(FONT="8p,red"): - fig_test.basemap( - region=[0, 9, 0, 9], projection="C3/3/9c", compass="jTL+w4c+d4.5+l" - ) - fig_test.basemap(compass="jBR+w5c+d-4.5+l") - - return fig_ref, fig_test + fig.basemap(region=[0, 9, 0, 9], projection="C3/3/9c", compass="jTL+w4c+d4.5+l") + fig.basemap(compass="jBR+w5c+d-4.5+l") + return fig -@check_figures_equal() +@pytest.mark.mpl_image_compare def test_config_font_annot(): """ - Test that setting `FONT_ANNOT` config changes both `FONT_ANNOT_PRIMARY` and - `FONT_ANNOT_SECONDARY`. + Test that setting FONT_ANNOT config changes both FONT_ANNOT_PRIMARY and + FONT_ANNOT_SECONDARY. """ - fig_ref = Figure() - with config(FONT_ANNOT_PRIMARY="6p,red", FONT_ANNOT_SECONDARY="6p,red"): - fig_ref.basemap(R="0/9/0/9", J="C3/3/9c", Tm="jTL+w4c+d4.5") - fig_ref.basemap(compass="jBR+w5c+d-4.5") - - fig_test = Figure() + fig = Figure() with config(FONT_ANNOT="6p,red"): - fig_test.basemap( - region=[0, 9, 0, 9], projection="C3/3/9c", compass="jTL+w4c+d4.5" - ) - fig_test.basemap(compass="jBR+w5c+d-4.5") - - return fig_ref, fig_test + fig.basemap(region=[0, 9, 0, 9], projection="C3/3/9c", compass="jTL+w4c+d4.5") + fig.basemap(compass="jBR+w5c+d-4.5") + return fig @pytest.mark.mpl_image_compare def test_config_format_time_map(): """ - Test that setting `FORMAT_TIME_MAP` config changes both - `FORMAT_TIME_PRIMARY_MAP` and `FORMAT_TIME_SECONDARY_MAP`. + Test that setting FORMAT_TIME_MAP config changes both + FORMAT_TIME_PRIMARY_MAP and FORMAT_TIME_SECONDARY_MAP. """ fig = Figure() with config(FORMAT_TIME_MAP="abbreviation"): @@ -107,8 +84,8 @@ def test_config_format_time_map(): @pytest.mark.mpl_image_compare def test_config_map_annot_offset(): """ - Test that setting `MAP_ANNOT_OFFSET` config changes both - `MAP_ANNOT_OFFSET_PRIMARY` and `MAP_ANNOT_OFFSET_SECONDARY`. + Test that setting MAP_ANNOT_OFFSET config changes both + MAP_ANNOT_OFFSET_PRIMARY and MAP_ANNOT_OFFSET_SECONDARY. """ fig = Figure() with config(MAP_ANNOT_OFFSET="15p"): @@ -124,8 +101,8 @@ def test_config_map_annot_offset(): @pytest.mark.mpl_image_compare def test_config_map_grid_cross_size(): """ - Test that setting `MAP_GRID_CROSS_SIZE` config changes both - `MAP_GRID_CROSS_SIZE_PRIMARY` and `MAP_GRID_CROSS_SIZE_SECONDARY`. + Test that setting MAP_GRID_CROSS_SIZE config changes both + MAP_GRID_CROSS_SIZE_PRIMARY and MAP_GRID_CROSS_SIZE_SECONDARY. """ fig = Figure() with config(MAP_GRID_CROSS_SIZE="3p"): @@ -142,8 +119,8 @@ def test_config_map_grid_cross_size(): @pytest.mark.mpl_image_compare def test_config_map_grid_pen(): """ - Test that setting `MAP_GRID_PEN` config changes both `MAP_GRID_PEN_PRIMARY` - and `MAP_GRID_PEN_SECONDARY`. + Test that setting MAP_GRID_PEN config changes both MAP_GRID_PEN_PRIMARY and + MAP_GRID_PEN_SECONDARY. """ fig = Figure() with config(MAP_GRID_PEN="thick,red"): @@ -160,8 +137,8 @@ def test_config_map_grid_pen(): @pytest.mark.mpl_image_compare def test_config_map_tick_length(): """ - Test that setting `MAP_TICK_LENGTH` config changes both - `MAP_TICK_LENGTH_PRIMARY` and `MAP_TICK_LENGTH_SECONDARY`. + Test that setting MAP_TICK_LENGTH config changes both + MAP_TICK_LENGTH_PRIMARY and MAP_TICK_LENGTH_SECONDARY. """ fig = Figure() with config(MAP_TICK_LENGTH="5p"): @@ -178,8 +155,8 @@ def test_config_map_tick_length(): @pytest.mark.mpl_image_compare def test_config_map_tick_pen(): """ - Test that setting `MAP_TICK_PEN` config changes both `MAP_TICK_PEN_PRIMARY` - and `MAP_TICK_PEN_SECONDARY`. + Test that setting MAP_TICK_PEN config changes both MAP_TICK_PEN_PRIMARY and + MAP_TICK_PEN_SECONDARY. """ fig = Figure() with config(MAP_TICK_PEN="thick,red"):