blob: 0acc3b3e086221365d38744c7b49b791903631e6 [file] [log] [blame]
Kuang-che Wue2fe6c32017-11-14 22:14:45 +08001# Copyright 2017 The Chromium OS Authors. All rights reserved.
2# Use of this source code is governed by a BSD-style license that can be
3# found in the LICENSE file.
4"""Test common module."""
5
6from __future__ import print_function
7import argparse
8import logging
9import os
10import tempfile
11import unittest
12
13from bisect_kit import common
14
15logger = logging.getLogger(__name__)
16
17
18class TestCommon(unittest.TestCase):
19 """Test functions in common module."""
20
21 def setUp(self):
22 self.log_file = tempfile.mktemp()
23
24 def tearDown(self):
25 if os.path.exists(self.log_file):
26 os.unlink(self.log_file)
27
28 def test_logging(self):
29 parser = argparse.ArgumentParser()
30 common.add_common_arguments(parser)
31 opts = parser.parse_args(['--log_file', self.log_file])
32 common.config_logging(opts)
33
34 logger.debug('test')
35 self.assertIn('test', open(self.log_file).read())
36
37
38if __name__ == '__main__':
39 unittest.main()