diff --git a/pygmt/tests/baseline/test_inset_aliases.png.dvc b/pygmt/tests/baseline/test_inset_aliases.png.dvc new file mode 100644 index 00000000000..da75d85a391 --- /dev/null +++ b/pygmt/tests/baseline/test_inset_aliases.png.dvc @@ -0,0 +1,4 @@ +outs: +- md5: f6ddb4129474219bfa30154614a189a5 + size: 31937 + path: test_inset_aliases.png diff --git a/pygmt/tests/baseline/test_inset_context_manager.png.dvc b/pygmt/tests/baseline/test_inset_context_manager.png.dvc new file mode 100644 index 00000000000..9a51cb7ae7f --- /dev/null +++ b/pygmt/tests/baseline/test_inset_context_manager.png.dvc @@ -0,0 +1,4 @@ +outs: +- md5: c06c3d8cbeb5b9b7ae977870b4c825d9 + size: 13322 + path: test_inset_context_manager.png diff --git a/pygmt/tests/test_inset.py b/pygmt/tests/test_inset.py index 1d87b5a77f5..2891a3f744f 100644 --- a/pygmt/tests/test_inset.py +++ b/pygmt/tests/test_inset.py @@ -1,42 +1,31 @@ """ Tests for the inset function. """ +import pytest from pygmt import Figure -from pygmt.helpers.testing import check_figures_equal -@check_figures_equal() +@pytest.mark.mpl_image_compare def test_inset_aliases(): """ Test the aliases for the inset function. """ - fig_ref, fig_test = Figure(), Figure() - fig_ref.basemap(R="MG+r2", B="afg") - with fig_ref.inset(D="jTL+w3.5c+o0.2c", M=0, F="+pgreen"): - fig_ref.basemap(R="g", J="G47/-20/4c", B="afg") + fig = Figure() + fig.basemap(region="MG+r2", frame="afg") + with fig.inset(position="jTL+w3.5c+o0.2c", margin=0, box="+pgreen"): + fig.basemap(region="g", projection="G47/-20/4c", frame="afg") + return fig - fig_test.basemap(region="MG+r2", frame="afg") - with fig_test.inset(position="jTL+w3.5c+o0.2c", margin=0, box="+pgreen"): - fig_test.basemap(region="g", projection="G47/-20/4c", frame="afg") - return fig_ref, fig_test - -@check_figures_equal() +@pytest.mark.mpl_image_compare def test_inset_context_manager(): """ Test that the inset context manager works and, once closed, plotting elements are added to the larger figure. """ - fig_ref, fig_test = Figure(), Figure() - - fig_ref.basemap(region=[-74, -69.5, 41, 43], projection="M9c", frame=True) - fig_ref.basemap(rose="jTR+w3c") # Pass rose argument with basemap before the inset - with fig_ref.inset(position="jBL+w3c+o0.2c", margin=0, box="+pblack"): - fig_ref.basemap(region=[-80, -65, 35, 50], projection="M3c", frame="afg") - - fig_test.basemap(region=[-74, -69.5, 41, 43], projection="M9c", frame=True) - with fig_test.inset(position="jBL+w3c+o0.2c", margin=0, box="+pblack"): - fig_test.basemap(region=[-80, -65, 35, 50], projection="M3c", frame="afg") - fig_test.basemap(rose="jTR+w3c") # Pass rose argument with basemap after the inset - - return fig_ref, fig_test + fig = Figure() + fig.basemap(region=[-74, -69.5, 41, 43], projection="M9c", frame=True) + with fig.inset(position="jBL+w3c+o0.2c", margin=0, box="+pblack"): + fig.basemap(region=[-80, -65, 35, 50], projection="M3c", frame="afg") + fig.basemap(rose="jTR+w3c") # Pass rose argument with basemap after the inset + return fig