Skip to content

Commit bca06d8

Browse files
committed
Simplify a few tests
1 parent 25eb225 commit bca06d8

2 files changed

Lines changed: 7 additions & 12 deletions

File tree

pygmt/src/legend.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -127,7 +127,7 @@ def legend( # noqa: PLR0913
127127
default=Position("TR", offset=0.2), # Default to TR with 0.2-cm offset.
128128
)
129129

130-
# Set default width to 0 (auto calculated) if height is given but width is not.
130+
# Set width to 0 (auto calculated) if height is given but width is not.
131131
if height is not None and width is None:
132132
width = 0
133133

pygmt/tests/test_legend.py

Lines changed: 6 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@
99
from pygmt import Figure
1010
from pygmt.exceptions import GMTInvalidInput, GMTTypeError
1111
from pygmt.helpers import GMTTempFile
12-
from pygmt.params import Position
1312

1413

1514
@pytest.fixture(scope="module", name="legend_spec")
@@ -74,7 +73,7 @@ def test_legend_entries():
7473
)
7574
fig.plot(data="@Table_5_11.txt", pen="1.5p,gray", label="My lines")
7675
fig.plot(data="@Table_5_11.txt", style="t0.15i", fill="orange", label="Oranges")
77-
fig.legend(position=Position("TR", cstype="outside", anchor="TR"))
76+
fig.legend(position="TR")
7877
return fig
7978

8079

@@ -87,11 +86,7 @@ def test_legend_specfile(legend_spec):
8786
Path(specfile.name).write_text(legend_spec, encoding="utf-8")
8887
fig = Figure()
8988
fig.basemap(projection="x6i", region=[0, 1, 0, 1], frame=True)
90-
fig.legend(
91-
specfile.name,
92-
position=Position("MC", cstype="outside", anchor="MC"),
93-
width="5i",
94-
)
89+
fig.legend(specfile.name, position="MC", width="5i")
9590
return fig
9691

9792

@@ -103,7 +98,7 @@ def test_legend_stringio(legend_spec):
10398
spec = io.StringIO(legend_spec)
10499
fig = Figure()
105100
fig.basemap(projection="x6i", region=[0, 1, 0, 1], frame=True)
106-
fig.legend(spec, position=Position("MC", cstype="outside", anchor="MC"), width="5i")
101+
fig.legend(spec, position="MC", width="5i")
107102
return fig
108103

109104

@@ -180,8 +175,8 @@ def test_legend_position_mixed_syntax(legend_spec):
180175
fig = Figure()
181176
fig.basemap(projection="x6i", region=[0, 1, 0, 1], frame=True)
182177
with pytest.raises(GMTInvalidInput):
183-
fig.legend(spec, position="JMC", width="5i")
178+
fig.legend(spec, position="jTL", width="5i")
184179
with pytest.raises(GMTInvalidInput):
185-
fig.legend(spec, position="JMC", height="5i")
180+
fig.legend(spec, position="jTL", height="5i")
186181
with pytest.raises(GMTInvalidInput):
187-
fig.legend(spec, position="JMC", line_spacing=2.0)
182+
fig.legend(spec, position="jTL", line_spacing=2.0)

0 commit comments

Comments
 (0)