OLD | NEW |
1 #!/usr/bin/python | 1 #!/usr/bin/python |
2 # Copyright (c) 2006-2009 The Chromium Authors. All rights reserved. | 2 # Copyright (c) 2006-2009 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.py and presubmit_canned_checks.py.""" | 6 """Unit tests for presubmit.py and presubmit_canned_checks.py.""" |
7 | 7 |
8 import os | 8 import os |
9 import StringIO | 9 import StringIO |
10 import unittest | 10 import unittest |
11 | 11 |
12 # Local imports | 12 # Local imports |
13 import gcl | 13 import gcl |
14 import gclient | 14 import gclient |
15 import presubmit | 15 import presubmit_support as presubmit |
16 import presubmit_canned_checks | 16 import presubmit_canned_checks |
17 | 17 |
18 | 18 |
19 class PresubmitTestsBase(unittest.TestCase): | 19 class PresubmitTestsBase(unittest.TestCase): |
20 """Setups and tear downs the mocks but doesn't test anything as-is.""" | 20 """Setups and tear downs the mocks but doesn't test anything as-is.""" |
21 def setUp(self): | 21 def setUp(self): |
22 self.original_IsFile = os.path.isfile | 22 self.original_IsFile = os.path.isfile |
23 def MockIsFile(f): | 23 def MockIsFile(f): |
24 dir = os.path.dirname(f) | 24 dir = os.path.dirname(f) |
25 return dir.endswith('haspresubmit') or dir == '' | 25 return dir.endswith('haspresubmit') or dir == '' |
(...skipping 659 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
685 self.failIf(presubmit_canned_checks.CheckTreeIsOpen( | 685 self.failIf(presubmit_canned_checks.CheckTreeIsOpen( |
686 self.MockInputApi(), presubmit.OutputApi, url='url_to_open', closed='0' | 686 self.MockInputApi(), presubmit.OutputApi, url='url_to_open', closed='0' |
687 )) | 687 )) |
688 self.failUnless(presubmit_canned_checks.CheckTreeIsOpen( | 688 self.failUnless(presubmit_canned_checks.CheckTreeIsOpen( |
689 self.MockInputApi(), presubmit.OutputApi, url='url_to_closed', closed='0' | 689 self.MockInputApi(), presubmit.OutputApi, url='url_to_closed', closed='0' |
690 )) | 690 )) |
691 | 691 |
692 | 692 |
693 if __name__ == '__main__': | 693 if __name__ == '__main__': |
694 unittest.main() | 694 unittest.main() |
OLD | NEW |