Skip to content

Commit 9e196f3

Browse files
committed
Move Figure.shift_origin tests into a separate test file (#3590)
1 parent c3af71d commit 9e196f3

File tree

4 files changed

+48
-40
lines changed

4 files changed

+48
-40
lines changed

pygmt/tests/baseline/test_figure_shift_origin.png.dvc

-4
This file was deleted.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
outs:
2+
- md5: 39b241fdd879271cf1e8cf1f73454706
3+
size: 9910
4+
hash: md5
5+
path: test_shift_origin.png

pygmt/tests/test_figure.py

-36
Original file line numberDiff line numberDiff line change
@@ -292,26 +292,6 @@ def test_figure_show():
292292
fig.show()
293293

294294

295-
@pytest.mark.mpl_image_compare
296-
def test_figure_shift_origin():
297-
"""
298-
Test if fig.shift_origin works.
299-
"""
300-
kwargs = {"region": [0, 3, 0, 5], "projection": "X3c/5c", "frame": 0}
301-
fig = Figure()
302-
# First call shift_origin without projection and region.
303-
# Test issue https://github.com/GenericMappingTools/pygmt/issues/514
304-
fig.shift_origin(xshift="2c", yshift="3c")
305-
fig.basemap(**kwargs)
306-
fig.shift_origin(xshift="4c")
307-
fig.basemap(**kwargs)
308-
fig.shift_origin(yshift="6c")
309-
fig.basemap(**kwargs)
310-
fig.shift_origin(xshift="-4c", yshift="6c")
311-
fig.basemap(**kwargs)
312-
return fig
313-
314-
315295
def test_figure_show_invalid_method():
316296
"""
317297
Test to check if an error is raised when an invalid method is passed to show.
@@ -407,22 +387,6 @@ def test_invalid_method(self):
407387
set_display(method="invalid")
408388

409389

410-
def test_figure_unsupported_xshift_yshift():
411-
"""
412-
Raise an exception if X/Y/xshift/yshift is used.
413-
"""
414-
fig = Figure()
415-
fig.basemap(region=[0, 1, 0, 1], projection="X1c/1c", frame=True)
416-
with pytest.raises(GMTInvalidInput):
417-
fig.plot(x=1, y=1, style="c3c", xshift="3c")
418-
with pytest.raises(GMTInvalidInput):
419-
fig.plot(x=1, y=1, style="c3c", X="3c")
420-
with pytest.raises(GMTInvalidInput):
421-
fig.plot(x=1, y=1, style="c3c", yshift="3c")
422-
with pytest.raises(GMTInvalidInput):
423-
fig.plot(x=1, y=1, style="c3c", Y="3c")
424-
425-
426390
class TestGetDefaultDisplayMethod:
427391
"""
428392
Test the _get_default_display_method function.

pygmt/tests/test_shift_origin.py

+43
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
"""
2+
Test Figure.shift_origin.
3+
"""
4+
5+
import pytest
6+
from pygmt.exceptions import GMTInvalidInput
7+
from pygmt.figure import Figure
8+
9+
10+
@pytest.mark.mpl_image_compare
11+
def test_shift_origin():
12+
"""
13+
Test if fig.shift_origin works.
14+
"""
15+
kwargs = {"region": [0, 3, 0, 5], "projection": "X3c/5c", "frame": 0}
16+
fig = Figure()
17+
# First call shift_origin without projection and region.
18+
# Test issue https://github.com/GenericMappingTools/pygmt/issues/514
19+
fig.shift_origin(xshift="2c", yshift="3c")
20+
fig.basemap(**kwargs)
21+
fig.shift_origin(xshift="4c")
22+
fig.basemap(**kwargs)
23+
fig.shift_origin(yshift="6c")
24+
fig.basemap(**kwargs)
25+
fig.shift_origin(xshift="-4c", yshift="6c")
26+
fig.basemap(**kwargs)
27+
return fig
28+
29+
30+
def test_shift_origin_unsupported_xshift_yshift():
31+
"""
32+
Raise an exception if X/Y/xshift/yshift is used.
33+
"""
34+
fig = Figure()
35+
fig.basemap(region=[0, 1, 0, 1], projection="X1c/1c", frame=True)
36+
with pytest.raises(GMTInvalidInput):
37+
fig.plot(x=1, y=1, style="c3c", xshift="3c")
38+
with pytest.raises(GMTInvalidInput):
39+
fig.plot(x=1, y=1, style="c3c", X="3c")
40+
with pytest.raises(GMTInvalidInput):
41+
fig.plot(x=1, y=1, style="c3c", yshift="3c")
42+
with pytest.raises(GMTInvalidInput):
43+
fig.plot(x=1, y=1, style="c3c", Y="3c")

0 commit comments

Comments
 (0)