Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(127)

Side by Side Diff: client/utils/logging_utils_test.py

Issue 1233303003: Migrate and merge logging_utils from swarming_bot into client/utils. (Closed) Base URL: git@github.com:luci/luci-py.git@master
Patch Set: Changed formatter Created 5 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 #!/usr/bin/env python 1 #!/usr/bin/env python
2 # Copyright 2014 The Swarming Authors. All rights reserved. 2 # Copyright 2015 The Swarming Authors. All rights reserved.
3 # Use of this source code is governed by the Apache v2.0 license that can be 3 # Use of this source code is governed under the Apache License, Version 2.0 that
4 # found in the LICENSE file. 4 # can be found in the LICENSE file.
5 5
6 import logging 6 import logging
7 import os 7 import os
8 import sys 8 import sys
9 import tempfile 9 import tempfile
10 import shutil 10 import shutil
11 import unittest 11 import unittest
12 import re 12 import re
13 13
14 # Import this first before manipulating sys.path to ensure it can load fine.
15 import logging_utils
16
17 ROOT_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__))) 14 ROOT_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
18 sys.path.insert(0, ROOT_DIR) 15 sys.path.insert(0, ROOT_DIR)
19 16
17 from utils import logging_utils
18
20 import test_env 19 import test_env
21 test_env.setup_test_env() 20 test_env.setup_test_env()
22 21
23 from depot_tools import auto_stub 22 from depot_tools import auto_stub
24 23
25 _LOG_HEADER = r'^%s \d\d\d\d-\d\d-\d\d \d\d:\d\d:\d\d\.\d\d\d: ' % os.getpid() 24 _LOG_HEADER = r'^%s \d\d\d\d-\d\d-\d\d \d\d:\d\d:\d\d\.\d\d\d: ' % os.getpid()
26 25
27 26
28 class TestLoggingUtils(auto_stub.TestCase): 27 class TestLoggingUtils(auto_stub.TestCase):
29 def test_Capture(self): 28 def test_Capture(self):
(...skipping 14 matching lines...) Expand all
44 result = f.read() 43 result = f.read()
45 finally: 44 finally:
46 shutil.rmtree(tmp_dir) 45 shutil.rmtree(tmp_dir)
47 # It'd be nice to figure out a way to ensure it's properly in UTC but it's 46 # It'd be nice to figure out a way to ensure it's properly in UTC but it's
48 # tricky to do reliably. 47 # tricky to do reliably.
49 self.assertTrue(re.match(_LOG_HEADER + 'DEBUG foo\n$', result), result) 48 self.assertTrue(re.match(_LOG_HEADER + 'DEBUG foo\n$', result), result)
50 49
51 50
52 if __name__ == '__main__': 51 if __name__ == '__main__':
53 unittest.main() 52 unittest.main()
OLDNEW
« no previous file with comments | « client/utils/logging_utils.py ('k') | client/utils/tools.py » ('j') | client/utils/tools.py » ('J')

Powered by Google App Engine
This is Rietveld 408576698