Skip to content

Commit 8a9684b

Browse files
authored
pygmt.params.Position: Validate the values of cstype (#4645)
1 parent 0e2f118 commit 8a9684b

2 files changed

Lines changed: 14 additions & 0 deletions

File tree

pygmt/params/position.py

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -186,6 +186,18 @@ def _validate(self):
186186
description="reference point",
187187
reason="Expect a valid 2-character justification code.",
188188
)
189+
case _:
190+
raise GMTValueError(
191+
self.cstype,
192+
description="cstype",
193+
choices=[
194+
"mapcoords",
195+
"plotcoords",
196+
"boxcoords",
197+
"inside",
198+
"outside",
199+
],
200+
)
189201
# Validate the anchor if specified.
190202
if self.anchor is not None and self.anchor not in _valid_anchors:
191203
raise GMTValueError(

pygmt/tests/test_params_position.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,8 @@ def test_params_position_invalid_location():
3737
"""
3838
Test that invalid location inputs raise GMTValueError.
3939
"""
40+
with pytest.raises(GMTValueError):
41+
Position((1, 2), cstype="invalid")
4042
with pytest.raises(GMTValueError):
4143
Position("invalid", cstype="mapcoords")
4244
with pytest.raises(GMTValueError):

0 commit comments

Comments
 (0)