diff options
| author | Thomi Richards <thomi.richards@canonical.com> | 2013-11-19 12:34:53 +1300 |
|---|---|---|
| committer | Thomi Richards <thomi.richards@canonical.com> | 2013-11-19 12:34:53 +1300 |
| commit | e59d18080f8187225745ec4aa87d0a2db731a372 (patch) | |
| tree | 53127250ee8c529ca87ba7e78111a36f350a901e /python | |
| parent | 4785ad1fa97c723d19af532efb6c0ea91d65dd03 (diff) | |
| download | subunit-e59d18080f8187225745ec4aa87d0a2db731a372.tar.gz | |
Add support for tags.
Diffstat (limited to 'python')
| -rw-r--r-- | python/subunit/_output.py | 10 | ||||
| -rw-r--r-- | python/subunit/tests/test_output_filter.py | 21 |
2 files changed, 30 insertions, 1 deletions
diff --git a/python/subunit/_output.py b/python/subunit/_output.py index 4bd93d1..788a19f 100644 --- a/python/subunit/_output.py +++ b/python/subunit/_output.py @@ -17,6 +17,7 @@ from argparse import ArgumentParser import datetime from functools import partial from sys import stdout +from string import split from subunit.v2 import StreamResultToBytes @@ -59,6 +60,12 @@ def parse_arguments(args=None, ParserClass=ArgumentParser): "not specified, the file will be sent wihtout a mime type.", default=None ) + common_args.add_argument( + "--tags", + help="A comma-separated list of tags to associate with this test.", + type=partial(split, sep=','), + default=None + ) sub_parsers = parser.add_subparsers(dest="action") final_state = "This is a final action: No more actions may be generated " \ @@ -124,7 +131,8 @@ def generate_bytestream(args, output_writer): output_writer.status( test_id=args.test_id, test_status=translate_command_name(args.action), - timestamp=create_timestamp() + timestamp=create_timestamp(), + test_tags=args.tags, ) output_writer.stopTestRun() diff --git a/python/subunit/tests/test_output_filter.py b/python/subunit/tests/test_output_filter.py index bddcc99..8b2f54b 100644 --- a/python/subunit/tests/test_output_filter.py +++ b/python/subunit/tests/test_output_filter.py @@ -89,6 +89,13 @@ class OutputFilterArgumentParserTests(TestCase): ) self.assertThat(args.mimetype, Equals("text/plain")) + def test_all_commands_accept_tags_argument(self): + for command in self._all_supported_commands: + args = safe_parse_arguments( + args=[command, 'foo', '--tags', "foo,bar,baz"] + ) + self.assertThat(args.tags, Equals(["foo","bar","baz"])) + class ByteStreamCompatibilityTests(TestCase): @@ -196,6 +203,20 @@ class ByteStreamCompatibilityTests(TestCase): ) ) + def test_tags_are_generated(self): + result = self._get_result_for( + ['exists', 'foo', '--tags', 'hello,world'] + ) + self.assertThat( + result._events[0], + MatchesCall( + call='status', + test_id='foo', + test_tags=set(['hello','world']), + timestamp=self._dummy_timestamp, + ) + ) + class FileChunkingTests(TestCase): |
