| Index: scripts/common/unittests/annotator_test.py
|
| diff --git a/scripts/common/unittests/annotator_test.py b/scripts/common/unittests/annotator_test.py
|
| index 9a9011c2991c144148f4bea3baeb569f695758a1..1b59bdfbfc498b678b2381dbdc93a264884bce14 100755
|
| --- a/scripts/common/unittests/annotator_test.py
|
| +++ b/scripts/common/unittests/annotator_test.py
|
| @@ -30,7 +30,8 @@ class TestAnnotationStreams(unittest.TestCase):
|
| return [line for line in self.buf.getvalue().rstrip().split('\n') if line]
|
|
|
| def testBasicUsage(self):
|
| - stream = annotator.StructuredAnnotationStream(stream=self.buf)
|
| + stream = annotator.StructuredAnnotationStream(
|
| + stream=self.buf, time_fn=lambda: 123456)
|
| with stream.step('one') as _:
|
| pass
|
| with stream.step('two') as _:
|
| @@ -39,20 +40,25 @@ class TestAnnotationStreams(unittest.TestCase):
|
| result = [
|
| '@@@SEED_STEP one@@@',
|
| '@@@STEP_CURSOR one@@@',
|
| + '@@@CURRENT_TIMESTAMP@123456@@@',
|
| '@@@STEP_STARTED@@@',
|
| '@@@STEP_CURSOR one@@@',
|
| + '@@@CURRENT_TIMESTAMP@123456@@@',
|
| '@@@STEP_CLOSED@@@',
|
| '@@@SEED_STEP two@@@',
|
| '@@@STEP_CURSOR two@@@',
|
| + '@@@CURRENT_TIMESTAMP@123456@@@',
|
| '@@@STEP_STARTED@@@',
|
| '@@@STEP_CURSOR two@@@',
|
| + '@@@CURRENT_TIMESTAMP@123456@@@',
|
| '@@@STEP_CLOSED@@@',
|
| ]
|
|
|
| self.assertEquals(result, self._getLines())
|
|
|
| def testStepAnnotations(self):
|
| - stream = annotator.StructuredAnnotationStream(stream=self.buf)
|
| + stream = annotator.StructuredAnnotationStream(
|
| + stream=self.buf, time_fn=lambda: 123456)
|
| with stream.step('one') as s:
|
| s.step_warnings()
|
| s.step_failure()
|
| @@ -73,6 +79,7 @@ class TestAnnotationStreams(unittest.TestCase):
|
| result = [
|
| '@@@SEED_STEP one@@@',
|
| '@@@STEP_CURSOR one@@@',
|
| + '@@@CURRENT_TIMESTAMP@123456@@@',
|
| '@@@STEP_STARTED@@@',
|
| '@@@STEP_WARNINGS@@@',
|
| '@@@STEP_FAILURE@@@',
|
| @@ -93,6 +100,7 @@ class TestAnnotationStreams(unittest.TestCase):
|
| '@@@STEP_LOG_LINE@full_perf_log@perf line two@@@',
|
| '@@@STEP_LOG_END_PERF@full_perf_log@full_perf@@@',
|
| '@@@STEP_CURSOR one@@@',
|
| + '@@@CURRENT_TIMESTAMP@123456@@@',
|
| '@@@STEP_CLOSED@@@',
|
| ]
|
|
|
| @@ -146,7 +154,7 @@ class TestAnnotationStreams(unittest.TestCase):
|
|
|
| def testStructured(self):
|
| stream = annotator.StructuredAnnotationStream(
|
| - stream=self.buf, flush_before=None)
|
| + stream=self.buf, flush_before=None, time_fn=lambda: 123456)
|
| step = annotator.StructuredAnnotationStep(
|
| annotation_stream=stream, stream=self.buf, flush_before=None)
|
| stream.step_cursor('one')
|
| @@ -160,8 +168,10 @@ class TestAnnotationStreams(unittest.TestCase):
|
|
|
| result = [
|
| '@@@STEP_CURSOR one@@@',
|
| + '@@@CURRENT_TIMESTAMP@123456@@@',
|
| '@@@STEP_STARTED@@@',
|
| '@@@STEP_CURSOR two@@@',
|
| + '@@@CURRENT_TIMESTAMP@123456@@@',
|
| '@@@STEP_STARTED@@@',
|
| '@@@STEP_CURSOR one@@@',
|
| '@@@STEP_CLOSED@@@',
|
|
|