@@ -21,19 +21,34 @@ def func(projection=None, region=None, frame=None, label=None, text=None, **kwar
21
21
return build_arg_list (alias .kwdict )
22
22
23
23
24
- def test_alias_system_one_alias ():
24
+ def test_alias_system_long_form ():
25
25
"""
26
- Test that the alias system works with a single alias .
26
+ Test that the alias system works with long-form parameters .
27
27
"""
28
+ # One parameter
28
29
assert func (projection = "X10c" ) == ["-JX10c" ]
30
+ # Multiple parameters.
29
31
assert func (projection = "H10c" , region = [0 , 10 , 0 , 20 ]) == ["-JH10c" , "-R0/10/0/20" ]
32
+ # Repeatable parameters.
30
33
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" ]
31
43
32
44
33
45
def test_alias_system_one_alias_short_form ():
34
46
"""
35
47
Test that the alias system works when short-form parameters coexist.
36
48
"""
49
+ # Long-form does not exist.
50
+ assert func (A = "abc" ) == ["-Aabc" ]
51
+
37
52
# Long-form exists but is not given, and short-form is given.
38
53
with pytest .warns (
39
54
SyntaxWarning ,
@@ -49,24 +64,19 @@ def test_alias_system_one_alias_short_form():
49
64
func (projection = "X10c" , J = "H10c" )
50
65
51
66
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
-
59
67
def test_alias_system_multiple_aliases_short_form ():
60
68
"""
61
69
Test that the alias system works with multiple aliases when short-form parameters
62
70
are used.
63
71
"""
72
+ # Long-form exists but is not given, and short-form is given.
64
73
with pytest .warns (
65
74
SyntaxWarning ,
66
75
match = "Short-form parameter 'U' is not recommended. Use long-form parameter 'label', 'text' instead." ,
67
76
):
68
77
assert func (U = "abcd+tefg" ) == ["-Uabcd+tefg" ]
69
78
79
+ # Coexistence of long-form and short-form parameters.
70
80
with pytest .raises (
71
81
GMTInvalidInput ,
72
82
match = "Parameter in short-form 'U' conflicts with long-form parameter 'label', 'text'." ,
0 commit comments