From 3cc605e9d56074ea59eba677dd50c94ab82d85ea Mon Sep 17 00:00:00 2001 From: Amador Pahim Date: Mon, 29 Jan 2018 11:43:20 +0100 Subject: [PATCH] test: include 'whiteboard' in preserved parameters Whiteboard was (probably accidentally) removed from the test attributes. This patch recreates the whiteboard. Signed-off-by: Amador Pahim --- avocado/core/test.py | 2 +- selftests/unit/test_runner_queue.py | 58 +++++++++++++++++++++++++++++ 2 files changed, 59 insertions(+), 1 deletion(-) create mode 100644 selftests/unit/test_runner_queue.py diff --git a/avocado/core/test.py b/avocado/core/test.py index 2d0f60b1..13f8345a 100644 --- a/avocado/core/test.py +++ b/avocado/core/test.py @@ -60,7 +60,7 @@ TEST_STATE_ATTRIBUTES = ('name', 'logdir', 'logfile', 'status', 'running', 'paused', 'time_start', 'time_elapsed', 'time_end', 'fail_reason', 'fail_class', 'traceback', - 'params', 'timeout') + 'params', 'timeout', 'whiteboard') class RawFileHandler(logging.FileHandler): diff --git a/selftests/unit/test_runner_queue.py b/selftests/unit/test_runner_queue.py new file mode 100644 index 00000000..b0f0a676 --- /dev/null +++ b/selftests/unit/test_runner_queue.py @@ -0,0 +1,58 @@ +import argparse +import shutil +import tempfile +import unittest + +from multiprocessing import queues + +from avocado.core.job import Job +from avocado.core.result import Result +from avocado.core.runner import TestRunner +from avocado.core.tree import TreeNode + + +class TestRunnerQueue(unittest.TestCase): + """ + Test the Runner/Test Queue + """ + + def setUp(self): + self.tmpdir = tempfile.mkdtemp(prefix="avocado_" + __name__) + args = argparse.Namespace(base_logdir=self.tmpdir) + self.job = Job(args) + self.result = Result(self.job) + + def _run_test(self, factory): + """ + Runs a test, specified by the test_factory + :param factory: the Avocado Test factory + :return: the last queue message from the test + """ + queue = queues.SimpleQueue() + runner = TestRunner(job=self.job, result=self.result) + runner._run_test(factory, queue) + while not queue.empty(): + msg = queue.get() + return msg + + def test_whiteboard(self): + """ + Tests if the whiteboard content is the expected one + """ + factory = ['WhiteBoard', + {'methodName': 'test', + 'tags': set([]), + 'params': ([TreeNode(name='')], ['/run/*']), + 'job': self.job, + 'modulePath': 'examples/tests/whiteboard.py', + 'base_logdir': self.tmpdir}] + msg = self._run_test(factory) + + self.assertEquals(msg['whiteboard'], 'ZGVmYXVsdCB3\n') + + def tearDown(self): + shutil.rmtree(self.tmpdir) + + +if __name__ == '__main__': + unittest.main() -- GitLab