@@ -126,17 +126,17 @@ def argparse_app():
126
126
127
127
128
128
def test_invalid_syntax (argparse_app ) -> None :
129
- out , err = run_cmd (argparse_app , 'speak "' )
129
+ _out , err = run_cmd (argparse_app , 'speak "' )
130
130
assert err [0 ] == "Invalid syntax: No closing quotation"
131
131
132
132
133
133
def test_argparse_basic_command (argparse_app ) -> None :
134
- out , err = run_cmd (argparse_app , 'say hello' )
134
+ out , _err = run_cmd (argparse_app , 'say hello' )
135
135
assert out == ['hello' ]
136
136
137
137
138
138
def test_argparse_remove_quotes (argparse_app ) -> None :
139
- out , err = run_cmd (argparse_app , 'say "hello there"' )
139
+ out , _err = run_cmd (argparse_app , 'say "hello there"' )
140
140
assert out == ['hello there' ]
141
141
142
142
@@ -150,64 +150,64 @@ def test_argparse_with_no_args(argparse_app) -> None:
150
150
def test_argparser_kwargs (argparse_app , capsys ) -> None :
151
151
"""Test with_argparser wrapper passes through kwargs to command function"""
152
152
argparse_app .do_say ('word' , keyword_arg = "foo" )
153
- out , err = capsys .readouterr ()
153
+ out , _err = capsys .readouterr ()
154
154
assert out == "foo\n "
155
155
156
156
157
157
def test_argparse_preserve_quotes (argparse_app ) -> None :
158
- out , err = run_cmd (argparse_app , 'tag mytag "hello"' )
158
+ out , _err = run_cmd (argparse_app , 'tag mytag "hello"' )
159
159
assert out [0 ] == '<mytag>"hello"</mytag>'
160
160
161
161
162
162
def test_argparse_custom_namespace (argparse_app ) -> None :
163
- out , err = run_cmd (argparse_app , 'test_argparse_ns' )
163
+ out , _err = run_cmd (argparse_app , 'test_argparse_ns' )
164
164
assert out [0 ] == 'custom'
165
165
166
166
167
167
def test_argparse_with_list (argparse_app ) -> None :
168
- out , err = run_cmd (argparse_app , 'speak -s hello world!' )
168
+ out , _err = run_cmd (argparse_app , 'speak -s hello world!' )
169
169
assert out == ['HELLO WORLD!' ]
170
170
171
171
172
172
def test_argparse_with_list_remove_quotes (argparse_app ) -> None :
173
- out , err = run_cmd (argparse_app , 'speak -s hello "world!"' )
173
+ out , _err = run_cmd (argparse_app , 'speak -s hello "world!"' )
174
174
assert out == ['HELLO WORLD!' ]
175
175
176
176
177
177
def test_argparse_with_list_preserve_quotes (argparse_app ) -> None :
178
- out , err = run_cmd (argparse_app , 'test_argparse_with_list_quotes "hello" person' )
178
+ out , _err = run_cmd (argparse_app , 'test_argparse_with_list_quotes "hello" person' )
179
179
assert out [0 ] == '"hello" person'
180
180
181
181
182
182
def test_argparse_with_list_custom_namespace (argparse_app ) -> None :
183
- out , err = run_cmd (argparse_app , 'test_argparse_with_list_ns' )
183
+ out , _err = run_cmd (argparse_app , 'test_argparse_with_list_ns' )
184
184
assert out [0 ] == 'custom'
185
185
186
186
187
187
def test_argparse_with_list_and_empty_doc (argparse_app ) -> None :
188
- out , err = run_cmd (argparse_app , 'speak -s hello world!' )
188
+ out , _err = run_cmd (argparse_app , 'speak -s hello world!' )
189
189
assert out == ['HELLO WORLD!' ]
190
190
191
191
192
192
def test_argparser_correct_args_with_quotes_and_midline_options (argparse_app ) -> None :
193
- out , err = run_cmd (argparse_app , "speak 'This is a' -s test of the emergency broadcast system!" )
193
+ out , _err = run_cmd (argparse_app , "speak 'This is a' -s test of the emergency broadcast system!" )
194
194
assert out == ['THIS IS A TEST OF THE EMERGENCY BROADCAST SYSTEM!' ]
195
195
196
196
197
197
def test_argparser_and_unknown_args_kwargs (argparse_app , capsys ) -> None :
198
198
"""Test with_argparser wrapper passing through kwargs to command function"""
199
199
argparse_app .do_speak ('' , keyword_arg = "foo" )
200
- out , err = capsys .readouterr ()
200
+ out , _err = capsys .readouterr ()
201
201
assert out == "foo\n "
202
202
203
203
204
204
def test_argparse_quoted_arguments_multiple (argparse_app ) -> None :
205
- out , err = run_cmd (argparse_app , 'say "hello there" "rick & morty"' )
205
+ out , _err = run_cmd (argparse_app , 'say "hello there" "rick & morty"' )
206
206
assert out == ['hello there rick & morty' ]
207
207
208
208
209
209
def test_argparse_help_docstring (argparse_app ) -> None :
210
- out , err = run_cmd (argparse_app , 'help say' )
210
+ out , _err = run_cmd (argparse_app , 'help say' )
211
211
assert out [0 ].startswith ('Usage: say' )
212
212
assert out [1 ] == ''
213
213
assert out [2 ] == 'Repeat what you tell me to.'
@@ -216,32 +216,32 @@ def test_argparse_help_docstring(argparse_app) -> None:
216
216
217
217
218
218
def test_argparse_help_description (argparse_app ) -> None :
219
- out , err = run_cmd (argparse_app , 'help tag' )
219
+ out , _err = run_cmd (argparse_app , 'help tag' )
220
220
assert out [0 ].startswith ('Usage: tag' )
221
221
assert out [1 ] == ''
222
222
assert out [2 ] == 'create a html tag'
223
223
224
224
225
225
def test_argparse_prog (argparse_app ) -> None :
226
- out , err = run_cmd (argparse_app , 'help tag' )
226
+ out , _err = run_cmd (argparse_app , 'help tag' )
227
227
progname = out [0 ].split (' ' )[1 ]
228
228
assert progname == 'tag'
229
229
230
230
231
231
def test_arglist (argparse_app ) -> None :
232
- out , err = run_cmd (argparse_app , 'arglist "we should" get these' )
232
+ out , _err = run_cmd (argparse_app , 'arglist "we should" get these' )
233
233
assert out [0 ] == 'True'
234
234
235
235
236
236
def test_arglist_kwargs (argparse_app , capsys ) -> None :
237
237
"""Test with_argument_list wrapper passes through kwargs to command function"""
238
238
argparse_app .do_arglist ('arg' , keyword_arg = "foo" )
239
- out , err = capsys .readouterr ()
239
+ out , _err = capsys .readouterr ()
240
240
assert out == "foo\n "
241
241
242
242
243
243
def test_preservelist (argparse_app ) -> None :
244
- out , err = run_cmd (argparse_app , 'preservelist foo "bar baz"' )
244
+ out , _err = run_cmd (argparse_app , 'preservelist foo "bar baz"' )
245
245
assert out [0 ] == "['foo', '\" bar baz\" ']"
246
246
247
247
@@ -332,70 +332,70 @@ def subcommand_app():
332
332
333
333
334
334
def test_subcommand_foo (subcommand_app ) -> None :
335
- out , err = run_cmd (subcommand_app , 'base foo -x2 5.0' )
335
+ out , _err = run_cmd (subcommand_app , 'base foo -x2 5.0' )
336
336
assert out == ['10.0' ]
337
337
338
338
339
339
def test_subcommand_bar (subcommand_app ) -> None :
340
- out , err = run_cmd (subcommand_app , 'base bar baz' )
340
+ out , _err = run_cmd (subcommand_app , 'base bar baz' )
341
341
assert out == ['((baz))' ]
342
342
343
343
344
344
def test_subcommand_invalid (subcommand_app ) -> None :
345
- out , err = run_cmd (subcommand_app , 'base baz' )
345
+ _out , err = run_cmd (subcommand_app , 'base baz' )
346
346
assert err [0 ].startswith ('Usage: base' )
347
347
assert err [1 ].startswith ("Error: argument SUBCOMMAND: invalid choice: 'baz'" )
348
348
349
349
350
350
def test_subcommand_base_help (subcommand_app ) -> None :
351
- out , err = run_cmd (subcommand_app , 'help base' )
351
+ out , _err = run_cmd (subcommand_app , 'help base' )
352
352
assert out [0 ].startswith ('Usage: base' )
353
353
assert out [1 ] == ''
354
354
assert out [2 ] == 'Base command help'
355
355
356
356
357
357
def test_subcommand_help (subcommand_app ) -> None :
358
358
# foo has no aliases
359
- out , err = run_cmd (subcommand_app , 'help base foo' )
359
+ out , _err = run_cmd (subcommand_app , 'help base foo' )
360
360
assert out [0 ].startswith ('Usage: base foo' )
361
361
assert out [1 ] == ''
362
362
assert out [2 ] == 'Positional Arguments:'
363
363
364
364
# bar has aliases (usage should never show alias name)
365
- out , err = run_cmd (subcommand_app , 'help base bar' )
365
+ out , _err = run_cmd (subcommand_app , 'help base bar' )
366
366
assert out [0 ].startswith ('Usage: base bar' )
367
367
assert out [1 ] == ''
368
368
assert out [2 ] == 'Positional Arguments:'
369
369
370
- out , err = run_cmd (subcommand_app , 'help base bar_1' )
370
+ out , _err = run_cmd (subcommand_app , 'help base bar_1' )
371
371
assert out [0 ].startswith ('Usage: base bar' )
372
372
assert out [1 ] == ''
373
373
assert out [2 ] == 'Positional Arguments:'
374
374
375
- out , err = run_cmd (subcommand_app , 'help base bar_2' )
375
+ out , _err = run_cmd (subcommand_app , 'help base bar_2' )
376
376
assert out [0 ].startswith ('Usage: base bar' )
377
377
assert out [1 ] == ''
378
378
assert out [2 ] == 'Positional Arguments:'
379
379
380
380
# helpless has aliases and no help text (usage should never show alias name)
381
- out , err = run_cmd (subcommand_app , 'help base helpless' )
381
+ out , _err = run_cmd (subcommand_app , 'help base helpless' )
382
382
assert out [0 ].startswith ('Usage: base helpless' )
383
383
assert out [1 ] == ''
384
384
assert out [2 ] == 'Positional Arguments:'
385
385
386
- out , err = run_cmd (subcommand_app , 'help base helpless_1' )
386
+ out , _err = run_cmd (subcommand_app , 'help base helpless_1' )
387
387
assert out [0 ].startswith ('Usage: base helpless' )
388
388
assert out [1 ] == ''
389
389
assert out [2 ] == 'Positional Arguments:'
390
390
391
- out , err = run_cmd (subcommand_app , 'help base helpless_2' )
391
+ out , _err = run_cmd (subcommand_app , 'help base helpless_2' )
392
392
assert out [0 ].startswith ('Usage: base helpless' )
393
393
assert out [1 ] == ''
394
394
assert out [2 ] == 'Positional Arguments:'
395
395
396
396
397
397
def test_subcommand_invalid_help (subcommand_app ) -> None :
398
- out , err = run_cmd (subcommand_app , 'help base baz' )
398
+ out , _err = run_cmd (subcommand_app , 'help base baz' )
399
399
assert out [0 ].startswith ('Usage: base' )
400
400
401
401
0 commit comments