From 8e0d770c4346b03975f0277652a955da6c6ef711 Mon Sep 17 00:00:00 2001 From: Tom Cobb Date: Thu, 2 Jun 2016 16:18:55 +0100 Subject: [PATCH] Added test for errors --- tests/test_core/test_process.py | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/tests/test_core/test_process.py b/tests/test_core/test_process.py index 278425480..2123e9aac 100644 --- a/tests/test_core/test_process.py +++ b/tests/test_core/test_process.py @@ -1,7 +1,6 @@ import unittest import sys import os -import time import logging logging.basicConfig() sys.path.append(os.path.join(os.path.dirname(__file__), "..", "..")) @@ -16,7 +15,7 @@ from malcolm.core.scheduler import Scheduler -class TestBlock(unittest.TestCase): +class TestProcess(unittest.TestCase): def test_init(self): s = MagicMock() @@ -39,5 +38,18 @@ def test_starting_process(self): p.stop() b.handle_request.assert_called_once_with(request) + def test_error(self): + s = Scheduler("sched") + p = Process("proc", s) + p.log_exception = MagicMock() + p.start() + request = MagicMock() + request.endpoint = ["anything"] + request.to_dict.return_value = "" + p.q.put(request) + p.stop() + p.log_exception.assert_called_once_with("Exception while handling %s", + "") + if __name__ == "__main__": unittest.main(verbosity=2)