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 checkout.py.""" | 6 """Unit tests for checkout.py.""" |
7 | 7 |
8 from __future__ import with_statement | 8 from __future__ import with_statement |
9 import logging | 9 import logging |
10 import os | 10 import os |
(...skipping 218 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
229 self.fail() | 229 self.fail() |
230 except checkout.PatchApplicationFailed, e: | 230 except checkout.PatchApplicationFailed, e: |
231 self.assertEquals(e.filename, 'svn_utils_test.txt') | 231 self.assertEquals(e.filename, 'svn_utils_test.txt') |
232 self.assertEquals(e.status, err_msg) | 232 self.assertEquals(e.status, err_msg) |
233 | 233 |
234 def _log(self): | 234 def _log(self): |
235 raise NotImplementedError() | 235 raise NotImplementedError() |
236 | 236 |
237 def _test_process(self, co): | 237 def _test_process(self, co): |
238 """Makes sure the process lambda is called correctly.""" | 238 """Makes sure the process lambda is called correctly.""" |
| 239 co.post_processors = [lambda *args: results.append(args)] |
239 co.prepare() | 240 co.prepare() |
240 ps = self.get_patches() | 241 ps = self.get_patches() |
241 results = [] | 242 results = [] |
242 co.apply_patch(ps, [lambda *args: results.append(args)]) | 243 co.apply_patch(ps) |
243 expected = [(co, p) for p in ps.patches] | 244 expected = [(co, p) for p in ps.patches] |
244 self.assertEquals(expected, results) | 245 self.assertEquals(expected, results) |
245 | 246 |
246 | 247 |
247 class SvnBaseTest(BaseTest): | 248 class SvnBaseTest(BaseTest): |
248 def setUp(self): | 249 def setUp(self): |
249 super(SvnBaseTest, self).setUp() | 250 super(SvnBaseTest, self).setUp() |
250 self.enabled = self.FAKE_REPOS.set_up_svn() | 251 self.enabled = self.FAKE_REPOS.set_up_svn() |
251 self.assertTrue(self.enabled) | 252 self.assertTrue(self.enabled) |
252 self.svn_trunk = 'trunk' | 253 self.svn_trunk = 'trunk' |
(...skipping 219 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
472 | 473 |
473 class RawCheckout(SvnBaseTest): | 474 class RawCheckout(SvnBaseTest): |
474 def setUp(self): | 475 def setUp(self): |
475 super(RawCheckout, self).setUp() | 476 super(RawCheckout, self).setUp() |
476 # Use a svn checkout as the base. | 477 # Use a svn checkout as the base. |
477 self.base_co = checkout.SvnCheckout( | 478 self.base_co = checkout.SvnCheckout( |
478 self.root_dir, self.name, None, None, self.svn_url) | 479 self.root_dir, self.name, None, None, self.svn_url) |
479 self.base_co.prepare() | 480 self.base_co.prepare() |
480 | 481 |
481 def _get_co(self, read_only): | 482 def _get_co(self, read_only): |
482 co = checkout.RawCheckout(self.root_dir, self.name) | 483 co = checkout.RawCheckout(self.root_dir, self.name, None) |
483 if read_only: | 484 if read_only: |
484 return checkout.ReadOnlyCheckout(co) | 485 return checkout.ReadOnlyCheckout(co) |
485 return co | 486 return co |
486 | 487 |
487 def _check(self, read_only): | 488 def _check(self, read_only): |
488 root = os.path.join(self.root_dir, self.name) | 489 root = os.path.join(self.root_dir, self.name) |
489 co = self._get_co(read_only) | 490 co = self._get_co(read_only) |
490 | 491 |
491 # A copy of BaseTest._check_base() | 492 # A copy of BaseTest._check_base() |
492 self.assertEquals(root, co.project_path) | 493 self.assertEquals(root, co.project_path) |
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
541 if '-v' in sys.argv: | 542 if '-v' in sys.argv: |
542 DEBUGGING = True | 543 DEBUGGING = True |
543 logging.basicConfig( | 544 logging.basicConfig( |
544 level=logging.DEBUG, | 545 level=logging.DEBUG, |
545 format='%(levelname)5s %(filename)15s(%(lineno)3d): %(message)s') | 546 format='%(levelname)5s %(filename)15s(%(lineno)3d): %(message)s') |
546 else: | 547 else: |
547 logging.basicConfig( | 548 logging.basicConfig( |
548 level=logging.ERROR, | 549 level=logging.ERROR, |
549 format='%(levelname)5s %(filename)15s(%(lineno)3d): %(message)s') | 550 format='%(levelname)5s %(filename)15s(%(lineno)3d): %(message)s') |
550 unittest.main() | 551 unittest.main() |
OLD | NEW |