3 # All rights reserved. This program and the accompanying materials
4 # are made available under the terms of the Apache License, Version 2.0
5 # which accompanies this distribution, and is available at
6 # http://www.apache.org/licenses/LICENSE-2.0
13 from functest.utils import functest_logger
14 from functest.utils.constants import CONST
17 class OSUtilsLogger(unittest.TestCase):
19 logging.disable(logging.CRITICAL)
22 with mock.patch('__builtin__.open', mock.mock_open()):
23 with mock.patch('functest.utils.functest_logger.os.path.exists',
25 mock.patch('functest.utils.functest_logger.'
27 mock.patch('functest.utils.functest_logger.'
28 'logging.config.dictConfig') as m:
29 self.logger = functest_logger.Logger('os_utils')
30 self.assertTrue(m.called)
31 with mock.patch('functest.utils.functest_logger.os.path.exists',
32 return_value=False), \
33 mock.patch('functest.utils.functest_logger.'
34 'logging.basicConfig') as m:
35 self.logger = functest_logger.Logger('os_utils')
36 self.assertTrue(m.called)
38 def test_is_debug_false(self):
39 CONST.CI_DEBUG = False
40 self.assertFalse(self.logger.is_debug())
42 def test_is_debug_true(self):
43 CONST.CI_DEBUG = "True"
44 self.assertTrue(self.logger.is_debug())
47 if __name__ == "__main__":
48 unittest.main(verbosity=2)