| OLD | NEW |
| 1 #!/usr/bin/env python | 1 #!/usr/bin/env python |
| 2 # Copyright (c) 2011 The Chromium Authors. All rights reserved. | 2 # Copyright (c) 2011 The Chromium Authors. All rights reserved. |
| 3 # Use of this source code is governed by a BSD-style license that can be | 3 # Use of this source code is governed by a BSD-style license that can be |
| 4 # found in the LICENSE file. | 4 # found in the LICENSE file. |
| 5 | 5 |
| 6 """Unit tests for gclient.py. | 6 """Unit tests for gclient.py. |
| 7 | 7 |
| 8 See gclient_smoketest.py for integration tests. | 8 See gclient_smoketest.py for integration tests. |
| 9 """ | 9 """ |
| 10 | 10 |
| 11 from __future__ import with_statement | 11 from __future__ import with_statement |
| 12 import Queue | 12 import Queue |
| 13 import logging | 13 import logging |
| 14 import os | 14 import os |
| 15 import sys | 15 import sys |
| 16 import unittest | 16 import unittest |
| 17 | 17 |
| 18 sys.path.insert(0, os.path.dirname(os.path.dirname(os.path.abspath(__file__)))) | 18 sys.path.insert(0, os.path.dirname(os.path.dirname(os.path.abspath(__file__)))) |
| 19 | 19 |
| 20 import gclient | 20 import gclient |
| 21 import gclient_utils | 21 import gclient_utils |
| 22 from tests import trial_dir | 22 from testing_support import trial_dir |
| 23 | 23 |
| 24 | 24 |
| 25 def write(filename, content): | 25 def write(filename, content): |
| 26 """Writes the content of a file and create the directories as needed.""" | 26 """Writes the content of a file and create the directories as needed.""" |
| 27 filename = os.path.abspath(filename) | 27 filename = os.path.abspath(filename) |
| 28 dirname = os.path.dirname(filename) | 28 dirname = os.path.dirname(filename) |
| 29 if not os.path.isdir(dirname): | 29 if not os.path.isdir(dirname): |
| 30 os.makedirs(dirname) | 30 os.makedirs(dirname) |
| 31 with open(filename, 'w') as f: | 31 with open(filename, 'w') as f: |
| 32 f.write(content) | 32 f.write(content) |
| (...skipping 218 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 251 sys.stdout = gclient_utils.MakeFileAutoFlush(sys.stdout) | 251 sys.stdout = gclient_utils.MakeFileAutoFlush(sys.stdout) |
| 252 sys.stdout = gclient_utils.MakeFileAnnotated(sys.stdout, include_zero=True) | 252 sys.stdout = gclient_utils.MakeFileAnnotated(sys.stdout, include_zero=True) |
| 253 sys.stderr = gclient_utils.MakeFileAutoFlush(sys.stderr) | 253 sys.stderr = gclient_utils.MakeFileAutoFlush(sys.stderr) |
| 254 sys.stderr = gclient_utils.MakeFileAnnotated(sys.stderr, include_zero=True) | 254 sys.stderr = gclient_utils.MakeFileAnnotated(sys.stderr, include_zero=True) |
| 255 logging.basicConfig( | 255 logging.basicConfig( |
| 256 level=[logging.ERROR, logging.WARNING, logging.INFO, logging.DEBUG][ | 256 level=[logging.ERROR, logging.WARNING, logging.INFO, logging.DEBUG][ |
| 257 min(sys.argv.count('-v'), 3)], | 257 min(sys.argv.count('-v'), 3)], |
| 258 format='%(relativeCreated)4d %(levelname)5s %(module)13s(' | 258 format='%(relativeCreated)4d %(levelname)5s %(module)13s(' |
| 259 '%(lineno)d) %(message)s') | 259 '%(lineno)d) %(message)s') |
| 260 unittest.main() | 260 unittest.main() |
| OLD | NEW |