From 9304d1b30eb553903ac7c77e238a6c93ff8d81fd Mon Sep 17 00:00:00 2001 From: Christophe Bedard Date: Wed, 6 May 2020 20:02:31 -0400 Subject: [PATCH] Add test for quiet processor option Signed-off-by: Christophe Bedard --- .../test/tracetools_analysis/test_processor.py | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/tracetools_analysis/test/tracetools_analysis/test_processor.py b/tracetools_analysis/test/tracetools_analysis/test_processor.py index e523e15..31e2e10 100644 --- a/tracetools_analysis/test/tracetools_analysis/test_processor.py +++ b/tracetools_analysis/test/tracetools_analysis/test_processor.py @@ -12,6 +12,8 @@ # See the License for the specific language governing permissions and # limitations under the License. +import contextlib +from io import StringIO from typing import Dict from typing import Set import unittest @@ -172,6 +174,21 @@ class TestProcessor(unittest.TestCase): result = processor.get_handler_by_type(StubHandler1) self.assertTrue(result is handler1) + def test_processor_quiet(self) -> None: + handler1 = StubHandler1() + mock_event = { + '_name': 'myeventname', + '_timestamp': 0, + 'cpu_id': 0, + } + temp_stdout = StringIO() + with contextlib.redirect_stdout(temp_stdout): + processor = Processor(handler1, quiet=True) + processor.process([mock_event]) + # Shouldn't be any output + output = temp_stdout.getvalue() + self.assertEqual(0, len(output), f'Processor was not quiet: "{output}"') + if __name__ == '__main__': unittest.main()