Chromium Code Reviews| 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 presubmit_support.py and presubmit_canned_checks.py.""" | 6 """Unit tests for presubmit_support.py and presubmit_canned_checks.py.""" |
| 7 | 7 |
| 8 # pylint is too confused. | 8 # pylint is too confused. |
| 9 # pylint: disable=E1101,E1103,R0201,W0212,W0403 | 9 # pylint: disable=E1101,E1103,R0201,W0212,W0403 |
| 10 | 10 |
| (...skipping 1374 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1385 Args: | 1385 Args: |
| 1386 check: the check to run. | 1386 check: the check to run. |
| 1387 content1: content which is expected to pass the check. | 1387 content1: content which is expected to pass the check. |
| 1388 content2: content which is expected to fail the check. | 1388 content2: content which is expected to fail the check. |
| 1389 error_type: the type of the error expected for content2. | 1389 error_type: the type of the error expected for content2. |
| 1390 """ | 1390 """ |
| 1391 change1 = presubmit.Change( | 1391 change1 = presubmit.Change( |
| 1392 'foo1', 'foo1\n', self.fake_root_dir, None, 0, 0, None) | 1392 'foo1', 'foo1\n', self.fake_root_dir, None, 0, 0, None) |
| 1393 input_api1 = self.MockInputApi(change1, False) | 1393 input_api1 = self.MockInputApi(change1, False) |
| 1394 affected_file = self.mox.CreateMock(presubmit.SvnAffectedFile) | 1394 affected_file = self.mox.CreateMock(presubmit.SvnAffectedFile) |
| 1395 input_api1.AffectedFiles(mox.IgnoreArg(), include_deletes=False).AndReturn( | 1395 input_api1.AffectedFiles(mox.IgnoreArg(), include_deletes=False, None).AndRe turn( |
|
M-A Ruel
2011/05/09 20:13:44
80 cols.
sail
2011/05/10 16:53:25
Done.
| |
| 1396 [affected_file]) | 1396 [affected_file]) |
| 1397 affected_file.NewContents().AndReturn([ | 1397 affected_file.NewContents().AndReturn([ |
| 1398 'ahoy', | 1398 'ahoy', |
| 1399 'yo' + content1, | 1399 'yo' + content1, |
| 1400 'hay', | 1400 'hay', |
| 1401 'yer', | 1401 'yer', |
| 1402 'ya']) | 1402 'ya']) |
| 1403 | 1403 |
| 1404 change2 = presubmit.Change( | 1404 change2 = presubmit.Change( |
| 1405 'foo2', 'foo2\n', self.fake_root_dir, None, 0, 0, None) | 1405 'foo2', 'foo2\n', self.fake_root_dir, None, 0, 0, None) |
| 1406 input_api2 = self.MockInputApi(change2, False) | 1406 input_api2 = self.MockInputApi(change2, False) |
| 1407 | 1407 |
| 1408 input_api2.AffectedFiles(mox.IgnoreArg(), include_deletes=False).AndReturn( | 1408 input_api2.AffectedFiles(mox.IgnoreArg(), include_deletes=False, None).AndRe turn( |
| 1409 [affected_file]) | 1409 [affected_file]) |
| 1410 affected_file.NewContents().AndReturn([ | 1410 affected_file.NewContents().AndReturn([ |
| 1411 'ahoy', | 1411 'ahoy', |
| 1412 'yo' + content2, | 1412 'yo' + content2, |
| 1413 'hay', | 1413 'hay', |
| 1414 'yer', | 1414 'yer', |
| 1415 'ya']) | 1415 'ya']) |
| 1416 affected_file.ChangedContents().AndReturn([ | 1416 affected_file.ChangedContents().AndReturn([ |
| 1417 (42, 'yo, ' + content2), | 1417 (42, 'yo, ' + content2), |
| 1418 (43, 'yer'), | 1418 (43, 'yer'), |
| (...skipping 725 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 2144 whitelist=['^a$', '^b$'], | 2144 whitelist=['^a$', '^b$'], |
| 2145 blacklist=['a']) | 2145 blacklist=['a']) |
| 2146 self.assertEqual(results, []) | 2146 self.assertEqual(results, []) |
| 2147 self.checkstdout( | 2147 self.checkstdout( |
| 2148 'Running %s\n' % presubmit.os.path.join('random_directory', 'b')) | 2148 'Running %s\n' % presubmit.os.path.join('random_directory', 'b')) |
| 2149 | 2149 |
| 2150 | 2150 |
| 2151 if __name__ == '__main__': | 2151 if __name__ == '__main__': |
| 2152 import unittest | 2152 import unittest |
| 2153 unittest.main() | 2153 unittest.main() |
| OLD | NEW |