summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorThomi Richards <thomi.richards@canonical.com>2013-12-09 17:28:26 +1300
committerThomi Richards <thomi.richards@canonical.com>2013-12-09 17:28:26 +1300
commit77e6b99c36d52d13ff68567d07b83307fbe64ed5 (patch)
treef592ed15ab6a8fed7587462760a2b7f6f337fc86
parentdd942d9a7d5f704ed512cbe5a9fef13223dd08be (diff)
downloadsubunit-77e6b99c36d52d13ff68567d07b83307fbe64ed5.tar.gz
Allow the use of the --tag argument without specifying a test id.
-rw-r--r--python/subunit/_output.py4
-rw-r--r--python/subunit/tests/test_output_filter.py31
2 files changed, 17 insertions, 18 deletions
diff --git a/python/subunit/_output.py b/python/subunit/_output.py
index 51aaa8f..14d7ad5 100644
--- a/python/subunit/_output.py
+++ b/python/subunit/_output.py
@@ -137,10 +137,6 @@ def parse_arguments(args=None, ParserClass=OptionParser):
options.attach_file = open(options.attach_file, 'rb')
except IOError as e:
parser.error("Cannot open %s (%s)" % (options.attach_file, e.strerror))
- if options.tags and not options.action:
- parser.error("Cannot specify --tag without a status command")
- if not (options.attach_file or options.action):
- parser.error("Must specify either --attach-file or a status command")
return options
diff --git a/python/subunit/tests/test_output_filter.py b/python/subunit/tests/test_output_filter.py
index f01d66a..673f89d 100644
--- a/python/subunit/tests/test_output_filter.py
+++ b/python/subunit/tests/test_output_filter.py
@@ -147,13 +147,8 @@ class ArgParserTests(TestCaseWithPatchedStderr):
)
self.assertThat(args.attach_file.name, Equals(tmp_file.name))
- def test_must_specify_argument(self):
- fn = lambda: safe_parse_arguments([])
- self.assertThat(
- fn,
- raises(RuntimeError('subunit-output: error: Must specify either '
- '--attach-file or a status command\n'))
- )
+ def test_can_run_without_args(self):
+ args = safe_parse_arguments([])
def test_cannot_specify_more_than_one_status_command(self):
fn = lambda: safe_parse_arguments(['--fail', 'foo', '--skip', 'bar'])
@@ -179,13 +174,9 @@ class ArgParserTests(TestCaseWithPatchedStderr):
'--file-name without --attach-file\n'))
)
- def test_cannot_specify_tags_without_status_command(self):
- fn = lambda: safe_parse_arguments(['--tag', 'foo'])
- self.assertThat(
- fn,
- raises(RuntimeError('subunit-output: error: Cannot specify '
- '--tag without a status command\n'))
- )
+ def test_can_specify_tags_without_status_command(self):
+ args = safe_parse_arguments(['--tag', 'foo'])
+ self.assertEqual(['foo'], args.tags)
def test_must_specify_tags_with_tags_options(self):
fn = lambda: safe_parse_arguments(['--fail', 'foo', '--tag'])
@@ -531,6 +522,18 @@ class FileDataTests(TestCase):
])
)
+ def test_can_specify_tags_without_test_status(self):
+ result = get_result_for([
+ '--tag',
+ 'foo',
+ ])
+
+ self.assertThat(
+ result._events,
+ MatchesListwise([
+ MatchesStatusCall(test_tags=set(['foo'])),
+ ])
+ )
class MatchesStatusCall(Matcher):