Skip to content

Commit c1fdfa5

Browse files
committed
Improve tests
1 parent 7ff71d1 commit c1fdfa5

File tree

1 file changed

+19
-9
lines changed

1 file changed

+19
-9
lines changed

pygmt/tests/test_alias_system.py

Lines changed: 19 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -21,19 +21,34 @@ def func(projection=None, region=None, frame=None, label=None, text=None, **kwar
2121
return build_arg_list(alias.kwdict)
2222

2323

24-
def test_alias_system_one_alias():
24+
def test_alias_system_long_form():
2525
"""
26-
Test that the alias system works with a single alias.
26+
Test that the alias system works with long-form parameters.
2727
"""
28+
# One parameter
2829
assert func(projection="X10c") == ["-JX10c"]
30+
# Multiple parameters.
2931
assert func(projection="H10c", region=[0, 10, 0, 20]) == ["-JH10c", "-R0/10/0/20"]
32+
# Repeatable parameters.
3033
assert func(frame=["WSen", "xaf", "yaf"]) == ["-BWSen", "-Bxaf", "-Byaf"]
34+
# Multiple long-form parameters.
35+
assert func(label="abcd", text="efg") == ["-Uabcd+tefg"]
36+
assert func(
37+
projection="H10c",
38+
region=[0, 10, 0, 20],
39+
label="abcd",
40+
text="efg",
41+
frame=["WSen", "xaf", "yaf"],
42+
) == ["-BWSen", "-Bxaf", "-Byaf", "-JH10c", "-R0/10/0/20", "-Uabcd+tefg"]
3143

3244

3345
def test_alias_system_one_alias_short_form():
3446
"""
3547
Test that the alias system works when short-form parameters coexist.
3648
"""
49+
# Long-form does not exist.
50+
assert func(A="abc") == ["-Aabc"]
51+
3752
# Long-form exists but is not given, and short-form is given.
3853
with pytest.warns(
3954
SyntaxWarning,
@@ -49,24 +64,19 @@ def test_alias_system_one_alias_short_form():
4964
func(projection="X10c", J="H10c")
5065

5166

52-
def test_alias_system_multiple_aliases():
53-
"""
54-
Test that the alias system works with multiple aliases.
55-
"""
56-
assert func(label="abcd", text="efg") == ["-Uabcd+tefg"]
57-
58-
5967
def test_alias_system_multiple_aliases_short_form():
6068
"""
6169
Test that the alias system works with multiple aliases when short-form parameters
6270
are used.
6371
"""
72+
# Long-form exists but is not given, and short-form is given.
6473
with pytest.warns(
6574
SyntaxWarning,
6675
match="Short-form parameter 'U' is not recommended. Use long-form parameter 'label', 'text' instead.",
6776
):
6877
assert func(U="abcd+tefg") == ["-Uabcd+tefg"]
6978

79+
# Coexistence of long-form and short-form parameters.
7080
with pytest.raises(
7181
GMTInvalidInput,
7282
match="Parameter in short-form 'U' conflicts with long-form parameter 'label', 'text'.",

0 commit comments

Comments
 (0)