-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
These arguments have a fixed sets of allowed values. The tests are checking that the code correctly displays error information when an unexpected argument value is supplied.
- Loading branch information
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -155,6 +155,21 @@ def test_input_files(self): | |
self.args['input_files'] = ['something', 'something_else'] | ||
self.check_args() | ||
|
||
def test_m_incorrect(self): | ||
[msg, result] = isolate_function_error(self.stage.parse_args, | ||
['-m', 'i']) | ||
err = "error: argument -m/--mode: invalid choice: 'i' "\ | ||
"(choose from 'f', 's', 'm')" | ||
self.assertIn(err, msg) | ||
|
||
def test_mode_incorrect(self): | ||
[msg, result] = isolate_function_error(self.stage.parse_args, | ||
['--mode', | ||
'incorrect']) | ||
err = "error: argument -m/--mode: invalid choice: 'incorrect' "\ | ||
"(choose from 'f', 's', 'm')" | ||
This comment has been minimized.
Sorry, something went wrong.
This comment has been minimized.
Sorry, something went wrong.
Evildoor
Author
Contributor
|
||
self.assertIn(err, msg) | ||
|
||
|
||
def add_arg(arg, val, short=False): | ||
def f(self): | ||
|
@@ -170,6 +185,25 @@ def f(self): | |
setattr(ProcessorStageArgsTestCase, 'test_%s_%s' % (arg, val), f) | ||
|
||
|
||
def add_arg_incorrect(arg, vals, short=False): | ||
This comment has been minimized.
Sorry, something went wrong.
mgolosova
Collaborator
|
||
if short: | ||
val = 'i' | ||
args = ['-' + arg[0], val] | ||
fname = 'test_%s_%s' % (arg[0], val) | ||
else: | ||
val = 'incorrect' | ||
args = ['--' + arg, val] | ||
fname = 'test_%s_%s' % (arg, val) | ||
|
||
def f(self): | ||
[msg, result] = isolate_function_error(self.stage.parse_args, args) | ||
err = "error: argument -%s/--%s: invalid choice: '%s' "\ | ||
"(choose from %s)" % (arg[0], arg, val, | ||
', '.join(["'%s'" % c for c in vals])) | ||
self.assertIn(err, msg) | ||
setattr(ProcessorStageArgsTestCase, fname, f) | ||
|
||
|
||
def add_mode(val, short=False): | ||
def f(self): | ||
if short: | ||
|
@@ -226,6 +260,8 @@ def f(self): | |
add_override_hdfs(a, v) | ||
for m in modes: | ||
add_override_mode(a, v, m) | ||
add_arg_incorrect(a, args_to_add[a], True) | ||
add_arg_incorrect(a, args_to_add[a]) | ||
|
||
|
||
for m in modes: | ||
|
Most possibly that the "correct" choices will still be one-character in the future, so the variant with
'incorrect'
looks more promising than the one with'i'
.Yet I have a question: are you sure that the part with
'(choose from: ...)'
should be specified explicitly? I mean, if one adds, I don`t know, mode'k'
-- this test still shouldn`t fail, right? Can we omit this part?