diff options
| author | Jonathan Lange <jml@canonical.com> | 2011-02-13 14:39:43 +0000 |
|---|---|---|
| committer | Jonathan Lange <jml@canonical.com> | 2011-02-13 14:39:43 +0000 |
| commit | 7fd32930b2d9bff0c4f8f823a313c03beedce451 (patch) | |
| tree | 518aabc9da51cd52364e27d69c9e62a8013ebff5 /python/subunit/test_results.py | |
| parent | cd10a295cc588e4ca93e741b094b6c2997153f37 (diff) | |
| download | subunit-git-7fd32930b2d9bff0c4f8f823a313c03beedce451.tar.gz | |
Add a time collapsing decorator.
Diffstat (limited to 'python/subunit/test_results.py')
| -rw-r--r-- | python/subunit/test_results.py | 19 |
1 files changed, 19 insertions, 0 deletions
diff --git a/python/subunit/test_results.py b/python/subunit/test_results.py index 12849f5..b3228c6 100644 --- a/python/subunit/test_results.py +++ b/python/subunit/test_results.py @@ -247,6 +247,25 @@ class TagCollapsingDecorator(TestResultDecorator): return self.decorated.tags(new_tags, gone_tags) +class TimeCollapsingDecorator(HookedTestResultDecorator): + """Only pass on the first and last of a consecutive sequence of times.""" + + def __init__(self, decorated): + HookedTestResultDecorator.__init__(self, decorated) + self._last_time = None + + def _before_event(self): + self.decorated.time(self._last_time) + self._last_time = None + + def time(self, a_time): + # Don't upcall, because we don't want to call _before_event, it's only + # for non-time events. + if self._last_time is None: + self.decorated.time(a_time) + self._last_time = a_time + + def all_true(bools): """Return True if all of 'bools' are True. False otherwise.""" for b in bools: |
