diff options
| author | Matthew Treinish <mtreinish@kortar.org> | 2016-01-04 18:29:56 -0500 |
|---|---|---|
| committer | Matthew Treinish <mtreinish@kortar.org> | 2020-03-14 09:31:08 -0400 |
| commit | 0e14d8be6126315c19c40905d75e55b2bfe7ba09 (patch) | |
| tree | 3110e217857d6479f416cb873dbb12b2fcdbd65a /python/subunit/tests | |
| parent | 26d31fa7c34019fad9038addf8114bbb4b656c92 (diff) | |
| download | subunit-git-0e14d8be6126315c19c40905d75e55b2bfe7ba09.tar.gz | |
Add options to output filter to set timestamps
This commit adds 2 new options to subunit-output, --start-time and
--stop-time, to specify a timestamp for the start and end of a test
in the output.
Diffstat (limited to 'python/subunit/tests')
| -rw-r--r-- | python/subunit/tests/test_output_filter.py | 63 |
1 files changed, 63 insertions, 0 deletions
diff --git a/python/subunit/tests/test_output_filter.py b/python/subunit/tests/test_output_filter.py index 0f61ac5..8444c75 100644 --- a/python/subunit/tests/test_output_filter.py +++ b/python/subunit/tests/test_output_filter.py @@ -472,6 +472,69 @@ class StatusStreamResultTests(TestCase): ]) ) +class TimeStampTests(TestCase): + scenarios = [ + (s, dict(status=s, option='--' + s)) for s in _FINAL_ACTIONS + ] + + _dummy_timestamp = datetime.datetime(1914, 6, 28, 10, 45, 2, 0, UTC) + + def setUp(self): + super(StatusStreamResultTests, self).setUp() + self.patch(_o, 'create_timestamp', lambda: self._dummy_timestamp) + self.test_id = self.getUniqueString() + + def test_no_timestamps(self): + result = get_result_for([self.option, self.test_id, f.name]) + self.assertThat( + result._events, + MatchesListwise([ + MatchesStatusCall(call='startTestRun'), + MatchesStatusCall(test_id=self.test_id, timestamp=self._dummy_timestamp), + MatchesStatusCall(test_id=self.test_id, timestamp=None), + MatchesStatusCall(call='stopTestRun'), + ])) + + def test_only_start_timestamp(self): + timestamp = datetime.datetime.utcnow() + result = get_result_for([self.option, self.test_id, f.name, + '--start-time', timestamp.isoformat()]) + self.assertThat( + result._events, + MatchesListwise([ + MatchesStatusCall(call='startTestRun'), + MatchesStatusCall(test_id=self.test_id, timestamp=timestamp), + MatchesStatusCall(test_id=self.test_id, timestamp=None), + MatchesStatusCall(call='stopTestRun'), + ])) + + def test_only_stop_timestamp(self): + timestamp = datetime.datetime.utcnow() + result = get_result_for([self.option, self.test_id, f.name, + '--stop-time', timestamp.isoformat()]) + self.assertThat( + result._events, + MatchesListwise([ + MatchesStatusCall(call='startTestRun'), + MatchesStatusCall(test_id=self.test_id, timestamp=self._dummy_timestamp), + MatchesStatusCall(test_id=self.test_id, timestamp=timestamp), + MatchesStatusCall(call='stopTestRun'), + ])) + + def test_start_and_stop_timestamp(self): + timestamp_start = datetime.datetime.utcnow() + timestamp_stop = timestamp_start + datetime.timedelta(minutes=5) + result = get_result_for([self.option, self.test_id, f.name, + '--start-time', timestamp_start.isoformat(), + '--stop-time', timestamp_stop.isoformat()]) + self.assertThat( + result._events, + MatchesListwise([ + MatchesStatusCall(call='startTestRun'), + MatchesStatusCall(test_id=self.test_id, timestamp=timestamp_start), + MatchesStatusCall(test_id=self.test_id, timestamp=timestamp_stop), + MatchesStatusCall(call='stopTestRun'), + ])) class FileDataTests(TestCase): |
