@@ -77,71 +77,71 @@ def test_get_commands_from_file():
7777 assert_array_equal (smartdispatch .get_commands_from_file (fileobj ), commands )
7878
7979
80- def test_get_commands_from_arguments ():
80+ def test_unfold_command ():
8181 # Test with one argument
82- args = [[ "ls" ]]
83- assert_equal (smartdispatch .get_commands_from_arguments ( args ), ["ls" ])
82+ cmd = "ls"
83+ assert_equal (smartdispatch .unfold_command ( cmd ), ["ls" ])
8484
85- args = [[ "echo 1" ]]
86- assert_equal (smartdispatch .get_commands_from_arguments ( args ), ["echo 1" ])
85+ cmd = "echo 1"
86+ assert_equal (smartdispatch .unfold_command ( cmd ), ["echo 1" ])
8787
8888 # Test two arguments
89- args = smartdispatch . unfold_arguments ([ "echo [1 2]" ])
90- assert_equal (smartdispatch .get_commands_from_arguments ( args ), ["echo 1" , "echo 2" ])
89+ cmd = "echo [1 2]"
90+ assert_equal (smartdispatch .unfold_command ( cmd ), ["echo 1" , "echo 2" ])
9191
92- args = smartdispatch . unfold_arguments ([ "echo test [1 2] yay" ])
93- assert_equal (smartdispatch .get_commands_from_arguments ( args ), ["echo test 1 yay" , "echo test 2 yay" ])
92+ cmd = "echo test [1 2] yay"
93+ assert_equal (smartdispatch .unfold_command ( cmd ), ["echo test 1 yay" , "echo test 2 yay" ])
9494
95- args = smartdispatch . unfold_arguments ([ "echo test[1 2]" ])
96- assert_equal (smartdispatch .get_commands_from_arguments ( args ), ["echo test1" , "echo test2" ])
95+ cmd = "echo test[1 2]"
96+ assert_equal (smartdispatch .unfold_command ( cmd ), ["echo test1" , "echo test2" ])
9797
98- args = smartdispatch . unfold_arguments ([ "echo test[1 2]yay" ])
99- assert_equal (smartdispatch .get_commands_from_arguments ( args ), ["echo test1yay" , "echo test2yay" ])
98+ cmd = "echo test[1 2]yay"
99+ assert_equal (smartdispatch .unfold_command ( cmd ), ["echo test1yay" , "echo test2yay" ])
100100
101101 # Test multiple folded arguments
102- args = smartdispatch . unfold_arguments ([ "python my_command.py" , " [0.01 0.000001 0.00000000001]" , "-1" , " [omicron mu]"])
103- assert_equal (smartdispatch .get_commands_from_arguments ( args ), ["python my_command.py 0.01 -1 omicron" ,
104- "python my_command.py 0.01 -1 mu" ,
105- "python my_command.py 0.000001 -1 omicron" ,
106- "python my_command.py 0.000001 -1 mu" ,
107- "python my_command.py 0.00000000001 -1 omicron" ,
108- "python my_command.py 0.00000000001 -1 mu" ])
102+ cmd = "python my_command.py [0.01 0.000001 0.00000000001] -1 [omicron mu]"
103+ assert_equal (smartdispatch .unfold_command ( cmd ), ["python my_command.py 0.01 -1 omicron" ,
104+ "python my_command.py 0.01 -1 mu" ,
105+ "python my_command.py 0.000001 -1 omicron" ,
106+ "python my_command.py 0.000001 -1 mu" ,
107+ "python my_command.py 0.00000000001 -1 omicron" ,
108+ "python my_command.py 0.00000000001 -1 mu" ])
109109
110110 # Test multiple folded arguments and not unfoldable brackets
111- args = smartdispatch . unfold_arguments ([ "python my_command.py [0.01 0.000001 0.00000000001] -1 \[[42 133,666]\] slow [omicron mu]" ])
112- assert_equal (smartdispatch .get_commands_from_arguments ( args ), ["python my_command.py 0.01 -1 [42] slow omicron" ,
113- "python my_command.py 0.01 -1 [42] slow mu" ,
114- "python my_command.py 0.01 -1 [133,666] slow omicron" ,
115- "python my_command.py 0.01 -1 [133,666] slow mu" ,
116- "python my_command.py 0.000001 -1 [42] slow omicron" ,
117- "python my_command.py 0.000001 -1 [42] slow mu" ,
118- "python my_command.py 0.000001 -1 [133,666] slow omicron" ,
119- "python my_command.py 0.000001 -1 [133,666] slow mu" ,
120- "python my_command.py 0.00000000001 -1 [42] slow omicron" ,
121- "python my_command.py 0.00000000001 -1 [42] slow mu" ,
122- "python my_command.py 0.00000000001 -1 [133,666] slow omicron" ,
123- "python my_command.py 0.00000000001 -1 [133,666] slow mu" ])
111+ cmd = "python my_command.py [0.01 0.000001 0.00000000001] -1 \[[42 133,666]\] slow [omicron mu]"
112+ assert_equal (smartdispatch .unfold_command ( cmd ), ["python my_command.py 0.01 -1 [42] slow omicron" ,
113+ "python my_command.py 0.01 -1 [42] slow mu" ,
114+ "python my_command.py 0.01 -1 [133,666] slow omicron" ,
115+ "python my_command.py 0.01 -1 [133,666] slow mu" ,
116+ "python my_command.py 0.000001 -1 [42] slow omicron" ,
117+ "python my_command.py 0.000001 -1 [42] slow mu" ,
118+ "python my_command.py 0.000001 -1 [133,666] slow omicron" ,
119+ "python my_command.py 0.000001 -1 [133,666] slow mu" ,
120+ "python my_command.py 0.00000000001 -1 [42] slow omicron" ,
121+ "python my_command.py 0.00000000001 -1 [42] slow mu" ,
122+ "python my_command.py 0.00000000001 -1 [133,666] slow omicron" ,
123+ "python my_command.py 0.00000000001 -1 [133,666] slow mu" ])
124124
125125 # Test multiple different folded arguments
126- args = smartdispatch . unfold_arguments ([ "python my_command.py [0.01 0.001] -[1:5] slow" ])
127- assert_equal (smartdispatch .get_commands_from_arguments ( args ), ["python my_command.py 0.01 -1 slow" ,
128- "python my_command.py 0.01 -2 slow" ,
129- "python my_command.py 0.01 -3 slow" ,
130- "python my_command.py 0.01 -4 slow" ,
131- "python my_command.py 0.001 -1 slow" ,
132- "python my_command.py 0.001 -2 slow" ,
133- "python my_command.py 0.001 -3 slow" ,
134- "python my_command.py 0.001 -4 slow" ])
135-
136- args = smartdispatch . unfold_arguments ([ "python my_command.py -[1:5] slow [0.01 0.001]" ])
137- assert_equal (smartdispatch .get_commands_from_arguments ( args ), ["python my_command.py -1 slow 0.01" ,
138- "python my_command.py -1 slow 0.001" ,
139- "python my_command.py -2 slow 0.01" ,
140- "python my_command.py -2 slow 0.001" ,
141- "python my_command.py -3 slow 0.01" ,
142- "python my_command.py -3 slow 0.001" ,
143- "python my_command.py -4 slow 0.01" ,
144- "python my_command.py -4 slow 0.001" ])
126+ cmd = "python my_command.py [0.01 0.001] -[1:5] slow"
127+ assert_equal (smartdispatch .unfold_command ( cmd ), ["python my_command.py 0.01 -1 slow" ,
128+ "python my_command.py 0.01 -2 slow" ,
129+ "python my_command.py 0.01 -3 slow" ,
130+ "python my_command.py 0.01 -4 slow" ,
131+ "python my_command.py 0.001 -1 slow" ,
132+ "python my_command.py 0.001 -2 slow" ,
133+ "python my_command.py 0.001 -3 slow" ,
134+ "python my_command.py 0.001 -4 slow" ])
135+
136+ cmd = "python my_command.py -[1:5] slow [0.01 0.001]"
137+ assert_equal (smartdispatch .unfold_command ( cmd ), ["python my_command.py -1 slow 0.01" ,
138+ "python my_command.py -1 slow 0.001" ,
139+ "python my_command.py -2 slow 0.01" ,
140+ "python my_command.py -2 slow 0.001" ,
141+ "python my_command.py -3 slow 0.01" ,
142+ "python my_command.py -3 slow 0.001" ,
143+ "python my_command.py -4 slow 0.01" ,
144+ "python my_command.py -4 slow 0.001" ])
145145
146146
147147def test_replace_uid_tag ():
0 commit comments