diff options
| author | Thomi Richards <thomi.richards@canonical.com> | 2013-11-19 09:34:26 +1300 |
|---|---|---|
| committer | Thomi Richards <thomi.richards@canonical.com> | 2013-11-19 09:34:26 +1300 |
| commit | f9b9c8ccebc2f7a9a42caabbfb11a81db02cfc99 (patch) | |
| tree | c1e1fc4831753a3dc646137c5b92bc944e2ec871 /python | |
| parent | 78bffde2922f10f68aef9db48cea3a00e57ff262 (diff) | |
| download | subunit-git-f9b9c8ccebc2f7a9a42caabbfb11a81db02cfc99.tar.gz | |
Add tests for timestamps, and add support for 'exists'.
Diffstat (limited to 'python')
| -rw-r--r-- | python/subunit/_output.py | 37 | ||||
| -rw-r--r-- | python/subunit/tests/test_output_filter.py | 55 |
2 files changed, 80 insertions, 12 deletions
diff --git a/python/subunit/_output.py b/python/subunit/_output.py index 9b467c1..4889e6f 100644 --- a/python/subunit/_output.py +++ b/python/subunit/_output.py @@ -43,17 +43,38 @@ def parse_arguments(args=None): identifies this test.""") sub_parsers = parser.add_subparsers(dest="action") - parser_start = sub_parsers.add_parser("start", help="Start a test.", - parents=[common_args]) + final_state = "This is a final action: No more actions may be generated " \ + "for this test id after this one." - parser_pass = sub_parsers.add_parser("pass", help="Pass a test.", - parents=[common_args]) + parser_start = sub_parsers.add_parser( + "start", + help="Start a test.", + parents=[common_args] + ) + + parser_pass = sub_parsers.add_parser( + "pass", + help="Pass a test. " + final_state, + parents=[common_args] + ) - parser_fail = sub_parsers.add_parser("fail", help="Fail a test.", - parents=[common_args]) + parser_fail = sub_parsers.add_parser( + "fail", + help="Fail a test. " + final_state, + parents=[common_args] + ) - parser_skip = sub_parsers.add_parser("skip", help="Skip a test.", - parents=[common_args]) + parser_skip = sub_parsers.add_parser( + "skip", + help="Skip a test. " + final_state, + parents=[common_args] + ) + + parser_exists = sub_parsers.add_parser( + "exists", + help="Marks a test as existing. " + final_state, + parents=[common_args] + ) return parser.parse_args(args) diff --git a/python/subunit/tests/test_output_filter.py b/python/subunit/tests/test_output_filter.py index fb56057..4031449 100644 --- a/python/subunit/tests/test_output_filter.py +++ b/python/subunit/tests/test_output_filter.py @@ -18,6 +18,7 @@ from io import BytesIO from collections import namedtuple +import datetime from testtools import TestCase from testtools.matchers import ( Equals, @@ -31,7 +32,9 @@ from subunit._output import ( generate_bytestream, parse_arguments, translate_command_name, + utc, ) +import subunit._output as _o class OutputFilterArgumentTests(TestCase): @@ -55,6 +58,9 @@ class OutputFilterArgumentTests(TestCase): def test_can_parse_skip_test(self): self._test_command('skip', self.getUniqueString()) + def test_can_parse_exists(self): + self._test_command('exists', self.getUniqueString()) + def test_command_translation(self): self.assertThat(translate_command_name('start'), Equals('inprogress')) self.assertThat(translate_command_name('pass'), Equals('success')) @@ -64,6 +70,12 @@ class OutputFilterArgumentTests(TestCase): class ByteStreamCompatibilityTests(TestCase): + _dummy_timestamp = datetime.datetime(2013, 1, 1, 0, 0, 0, 0, utc) + + def setUp(self): + super(ByteStreamCompatibilityTests, self).setUp() + self.patch(_o, 'create_timestamp', lambda: self._dummy_timestamp) + def _get_result_for(self, *commands): """Get a result object from *commands. @@ -94,7 +106,12 @@ class ByteStreamCompatibilityTests(TestCase): self.assertThat( result._events[0], - MatchesCall(call='status', test_id='foo', test_status='inprogress') + MatchesCall( + call='status', + test_id='foo', + test_status='inprogress', + timestamp=self._dummy_timestamp, + ) ) def test_pass_generates_success(self): @@ -104,7 +121,12 @@ class ByteStreamCompatibilityTests(TestCase): self.assertThat( result._events[0], - MatchesCall(call='status', test_id='foo', test_status='success') + MatchesCall( + call='status', + test_id='foo', + test_status='success', + timestamp=self._dummy_timestamp, + ) ) def test_fail_generates_fail(self): @@ -114,7 +136,12 @@ class ByteStreamCompatibilityTests(TestCase): self.assertThat( result._events[0], - MatchesCall(call='status', test_id='foo', test_status='fail') + MatchesCall( + call='status', + test_id='foo', + test_status='fail', + timestamp=self._dummy_timestamp, + ) ) def test_skip_generates_skip(self): @@ -124,7 +151,27 @@ class ByteStreamCompatibilityTests(TestCase): self.assertThat( result._events[0], - MatchesCall(call='status', test_id='foo', test_status='skip') + MatchesCall( + call='status', + test_id='foo', + test_status='skip', + timestamp=self._dummy_timestamp, + ) + ) + + def test_exists_generates_exists(self): + result = self._get_result_for( + ['exists', 'foo'], + ) + + self.assertThat( + result._events[0], + MatchesCall( + call='status', + test_id='foo', + test_status='exists', + timestamp=self._dummy_timestamp, + ) ) |
