Brad Bishop | 6e60e8b | 2018-02-01 10:27:11 -0500 | [diff] [blame^] | 1 | # Copyright (C) 2016 Intel Corporation |
| 2 | # Released under the MIT license (see COPYING.MIT) |
| 3 | |
| 4 | import sys |
| 5 | import os |
| 6 | |
| 7 | import unittest |
| 8 | import logging |
| 9 | import os |
| 10 | |
| 11 | logger = logging.getLogger("oeqa") |
| 12 | logger.setLevel(logging.INFO) |
| 13 | consoleHandler = logging.StreamHandler() |
| 14 | formatter = logging.Formatter('OEQATest: %(message)s') |
| 15 | consoleHandler.setFormatter(formatter) |
| 16 | logger.addHandler(consoleHandler) |
| 17 | |
| 18 | def setup_sys_path(): |
| 19 | directory = os.path.dirname(os.path.abspath(__file__)) |
| 20 | oeqa_lib = os.path.realpath(os.path.join(directory, '../../../')) |
| 21 | if not oeqa_lib in sys.path: |
| 22 | sys.path.insert(0, oeqa_lib) |
| 23 | |
| 24 | class TestBase(unittest.TestCase): |
| 25 | def setUp(self): |
| 26 | self.logger = logger |
| 27 | directory = os.path.dirname(os.path.abspath(__file__)) |
| 28 | self.cases_path = os.path.join(directory, 'cases') |
| 29 | |
| 30 | def _testLoader(self, d={}, modules=[], tests=[], filters={}): |
| 31 | from oeqa.core.context import OETestContext |
| 32 | tc = OETestContext(d, self.logger) |
| 33 | tc.loadTests(self.cases_path, modules=modules, tests=tests, |
| 34 | filters=filters) |
| 35 | return tc |