diff options
author | Thomi Richards <thomi.richards@canonical.com> | 2013-11-25 18:14:57 +1300 |
---|---|---|
committer | Thomi Richards <thomi.richards@canonical.com> | 2013-11-25 18:14:57 +1300 |
commit | 9c24b5dbb4e3a2ff55372ffca620bb1cda3ef875 (patch) | |
tree | 2e730a8cf06306c1e17cbb6a9df895164ab068bf | |
parent | 81c8839bd41bc0d25f478025083c8cd2d1a9afa8 (diff) | |
download | subunit-9c24b5dbb4e3a2ff55372ffca620bb1cda3ef875.tar.gz |
Added test for poorly specified tags.
-rw-r--r-- | python/subunit/_output.py | 4 | ||||
-rw-r--r-- | python/subunit/tests/test_output_filter.py | 7 |
2 files changed, 10 insertions, 1 deletions
diff --git a/python/subunit/_output.py b/python/subunit/_output.py index 24d63dc..66ff5df 100644 --- a/python/subunit/_output.py +++ b/python/subunit/_output.py @@ -150,12 +150,14 @@ def set_status_cb(option, opt_str, value, parser, status_name): raise OptionValueError("argument %s: Only one status may be specified at once." % option) if len(parser.rargs) == 0: - raise OptionValueError("argument %s: must specify a single TEST_ID.") + raise OptionValueError("argument %s: must specify a single TEST_ID." % option) parser.values.action = status_name parser.values.test_id = parser.rargs.pop(0) def set_tags_cb(option, opt_str, value, parser): + if not parser.rargs: + raise OptionValueError("Must specify at least one tag with --tags") parser.values.tags = parser.rargs.pop(0).split(',') diff --git a/python/subunit/tests/test_output_filter.py b/python/subunit/tests/test_output_filter.py index f3000ad..a31ae2b 100644 --- a/python/subunit/tests/test_output_filter.py +++ b/python/subunit/tests/test_output_filter.py @@ -187,6 +187,13 @@ class ArgParserTests(TestCaseWithPatchedStderr): '--tags without a status command\n')) ) + def test_must_specify_tags_with_tags_options(self): + fn = lambda: safe_parse_arguments(['--fail', 'foo', '--tags']) + self.assertThat( + fn, + raises(RuntimeError('subunit-output: error: Must specify at least one tag with --tags\n')) + ) + def get_result_for(commands): """Get a result object from *commands. |