diff options
author | Thomi Richards <thomi.richards@canonical.com> | 2013-11-19 12:47:22 +1300 |
---|---|---|
committer | Thomi Richards <thomi.richards@canonical.com> | 2013-11-19 12:47:22 +1300 |
commit | 9ef306018ca4057c46a5627379e8671eb1b8db26 (patch) | |
tree | 3cb0d7b84838da351b3a029c8bc6dfe85ff27051 | |
parent | e59d18080f8187225745ec4aa87d0a2db731a372 (diff) | |
download | subunit-9ef306018ca4057c46a5627379e8671eb1b8db26.tar.gz |
Add support for expected fail and unexpected success test statuses.
-rw-r--r-- | python/subunit/_output.py | 16 | ||||
-rw-r--r-- | python/subunit/tests/test_output_filter.py | 42 |
2 files changed, 57 insertions, 1 deletions
diff --git a/python/subunit/_output.py b/python/subunit/_output.py index 788a19f..ba6d0ce 100644 --- a/python/subunit/_output.py +++ b/python/subunit/_output.py @@ -101,6 +101,20 @@ def parse_arguments(args=None, ParserClass=ArgumentParser): parents=[common_args] ) + parser_expected_fail = sub_parsers.add_parser( + "expected-fail", + help="Marks a test as failing expectedly (this is not counted as a "\ + "failure). " + final_state, + parents=[common_args], + ) + + parser_unexpected_success = sub_parsers.add_parser( + "unexpected-success", + help="Marks a test as succeeding unexpectedly (this is counted as a "\ + "failure). " + final_state, + parents=[common_args], + ) + return parser.parse_args(args) @@ -112,6 +126,8 @@ def translate_command_name(command_name): return { 'start': 'inprogress', 'pass': 'success', + 'expected-fail': 'xfail', + 'unexpected-success': 'uxsuccess', }.get(command_name, command_name) diff --git a/python/subunit/tests/test_output_filter.py b/python/subunit/tests/test_output_filter.py index 8b2f54b..2a70a2c 100644 --- a/python/subunit/tests/test_output_filter.py +++ b/python/subunit/tests/test_output_filter.py @@ -55,7 +55,15 @@ safe_parse_arguments = partial(parse_arguments, ParserClass=SafeArgumentParser) class OutputFilterArgumentParserTests(TestCase): - _all_supported_commands = ('start', 'pass', 'fail', 'skip', 'exists') + _all_supported_commands = ( + 'exists', + 'expected-fail', + 'fail', + 'pass', + 'skip', + 'start', + 'unexpected-success', + ) def _test_command(self, command, test_id): args = safe_parse_arguments(args=[command, test_id]) @@ -70,6 +78,8 @@ class OutputFilterArgumentParserTests(TestCase): def test_command_translation(self): self.assertThat(translate_command_name('start'), Equals('inprogress')) self.assertThat(translate_command_name('pass'), Equals('success')) + self.assertThat(translate_command_name('expected-fail'), Equals('xfail')) + self.assertThat(translate_command_name('unexpected-success'), Equals('uxsuccess')) for command in ('fail', 'skip', 'exists'): self.assertThat(translate_command_name(command), Equals(command)) @@ -203,6 +213,36 @@ class ByteStreamCompatibilityTests(TestCase): ) ) + def test_expected_fail_generates_xfail(self): + result = self._get_result_for( + ['expected-fail', 'foo'], + ) + + self.assertThat( + result._events[0], + MatchesCall( + call='status', + test_id='foo', + test_status='xfail', + timestamp=self._dummy_timestamp, + ) + ) + + def test_unexpected_success_generates_uxsuccess(self): + result = self._get_result_for( + ['unexpected-success', 'foo'], + ) + + self.assertThat( + result._events[0], + MatchesCall( + call='status', + test_id='foo', + test_status='uxsuccess', + timestamp=self._dummy_timestamp, + ) + ) + def test_tags_are_generated(self): result = self._get_result_for( ['exists', 'foo', '--tags', 'hello,world'] |