Added test for poorly specified tags.
authorThomi Richards <thomi.richards@canonical.com>
Mon, 25 Nov 2013 05:14:57 +0000 (18:14 +1300)
committerThomi Richards <thomi.richards@canonical.com>
Mon, 25 Nov 2013 05:14:57 +0000 (18:14 +1300)
python/subunit/_output.py
python/subunit/tests/test_output_filter.py

index 24d63dcd853f9906b62bfe01e4fba3c1e0aa5fae..66ff5df438e2ca542978949f9b8a41bf37600035 100644 (file)
@@ -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(',')
 
 
index f3000ad5f16540d6d94af9cc45538f3d50a3b800..a31ae2bcbb9fb759324695b253f70af8851e60a3 100644 (file)
@@ -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.