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

Side by Side Diff: tests/gclient_scm_test.py

Issue 8508017: Standardize the sys.path fix up and fix a few pylint warnings. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/tools/depot_tools
Patch Set: rebase against HEAD Created 9 years, 1 month 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 | Annotate | Revision Log
« no previous file with comments | « tests/gcl_unittest.py ('k') | tests/gclient_smoketest.py » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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_scm.py.""" 6 """Unit tests for gclient_scm.py."""
7 7
8 # pylint: disable=E1101,E1103,W0403 8 # pylint: disable=E1103
9 9
10 import logging
11 import os
10 # Import before super_mox to keep valid references. 12 # Import before super_mox to keep valid references.
11 from os import rename 13 from os import rename
12 from shutil import rmtree 14 from shutil import rmtree
13 from subprocess import Popen, PIPE, STDOUT 15 from subprocess import Popen, PIPE, STDOUT
Dirk Pranke 2011/11/09 23:18:47 Nit: I think all of the "from"s are supposed to be
M-A Ruel 2011/11/10 15:38:21 I think http://google-styleguide.googlecode.com/sv
16 import sys
14 import tempfile 17 import tempfile
15 import unittest 18 import unittest
16 import __builtin__ 19 import __builtin__
17 20
18 # Fixes include path. 21 sys.path.insert(0, os.path.dirname(os.path.dirname(os.path.abspath(__file__))))
19 from super_mox import mox, StdoutCheck, TestCaseUtils, SuperMoxTestBase
20 22
21 import logging 23 from super_mox import mox, StdoutCheck, SuperMoxTestBase
22 import sys 24 from super_mox import TestCaseUtils
25
23 import gclient_scm 26 import gclient_scm
24 import subprocess2 27 import subprocess2
25 28
26 # Shortcut since this function is used often 29 # Shortcut since this function is used often
27 join = gclient_scm.os.path.join 30 join = gclient_scm.os.path.join
28 31
29 32
30 class GCBaseTestCase(object): 33 class GCBaseTestCase(object):
31 def assertRaisesError(self, msg, fn, *args, **kwargs): 34 def assertRaisesError(self, msg, fn, *args, **kwargs):
32 """Like unittest's assertRaises() but checks for Gclient.Error.""" 35 """Like unittest's assertRaises() but checks for Gclient.Error."""
36 # pylint: disable=E1101
33 try: 37 try:
34 fn(*args, **kwargs) 38 fn(*args, **kwargs)
35 except gclient_scm.gclient_utils.Error, e: 39 except gclient_scm.gclient_utils.Error, e:
36 self.assertEquals(e.args[0], msg) 40 self.assertEquals(e.args[0], msg)
37 else: 41 else:
38 self.fail('%s not raised' % msg) 42 self.fail('%s not raised' % msg)
39 43
40 44
41 class BaseTestCase(GCBaseTestCase, SuperMoxTestBase): 45 class BaseTestCase(GCBaseTestCase, SuperMoxTestBase):
42 def setUp(self): 46 def setUp(self):
(...skipping 202 matching lines...) Expand 10 before | Expand all | Expand 10 after
245 items = [ 249 items = [
246 ('~ ', '.'), 250 ('~ ', '.'),
247 ] 251 ]
248 gclient_scm.scm.SVN.CaptureStatus(self.base_path).AndReturn(items) 252 gclient_scm.scm.SVN.CaptureStatus(self.base_path).AndReturn(items)
249 file_path = join(self.base_path, '.') 253 file_path = join(self.base_path, '.')
250 gclient_scm.os.path.exists(file_path).AndReturn(True) 254 gclient_scm.os.path.exists(file_path).AndReturn(True)
251 gclient_scm.os.path.isfile(file_path).AndReturn(False) 255 gclient_scm.os.path.isfile(file_path).AndReturn(False)
252 gclient_scm.os.path.islink(file_path).AndReturn(False) 256 gclient_scm.os.path.islink(file_path).AndReturn(False)
253 gclient_scm.os.path.isdir(file_path).AndReturn(True) 257 gclient_scm.os.path.isdir(file_path).AndReturn(True)
254 gclient_scm.gclient_utils.RemoveDirectory(file_path) 258 gclient_scm.gclient_utils.RemoveDirectory(file_path)
259 # pylint: disable=E1120
255 gclient_scm.os.path.isdir(self.base_path).AndReturn(False) 260 gclient_scm.os.path.isdir(self.base_path).AndReturn(False)
256 # The mock is unbound so self is not necessary.
257 # pylint: disable=E1120
258 gclient_scm.SVNWrapper.update(options, [], ['.']) 261 gclient_scm.SVNWrapper.update(options, [], ['.'])
259 262
260 self.mox.ReplayAll() 263 self.mox.ReplayAll()
261 scm = self._scm_wrapper(url=self.url, root_dir=self.root_dir, 264 scm = self._scm_wrapper(url=self.url, root_dir=self.root_dir,
262 relpath=self.relpath) 265 relpath=self.relpath)
263 file_list2 = [] 266 file_list2 = []
264 scm.revert(options, self.args, file_list2) 267 scm.revert(options, self.args, file_list2)
265 self.checkstdout(('%s\n' % file_path)) 268 self.checkstdout(('%s\n' % file_path))
266 269
267 def testStatus(self): 270 def testStatus(self):
(...skipping 694 matching lines...) Expand 10 before | Expand all | Expand 10 after
962 965
963 if __name__ == '__main__': 966 if __name__ == '__main__':
964 if '-v' in sys.argv: 967 if '-v' in sys.argv:
965 logging.basicConfig( 968 logging.basicConfig(
966 level=logging.DEBUG, 969 level=logging.DEBUG,
967 format='%(asctime).19s %(levelname)s %(filename)s:' 970 format='%(asctime).19s %(levelname)s %(filename)s:'
968 '%(lineno)s %(message)s') 971 '%(lineno)s %(message)s')
969 unittest.main() 972 unittest.main()
970 973
971 # vim: ts=2:sw=2:tw=80:et: 974 # vim: ts=2:sw=2:tw=80:et:
OLDNEW
« no previous file with comments | « tests/gcl_unittest.py ('k') | tests/gclient_smoketest.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698