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

Side by Side Diff: tests/presubmit_unittest.py

Issue 556092: Remove stale revert.py unit test and fix another test I broke in r37487. (Closed)
Patch Set: Created 10 years, 10 months 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
« no previous file with comments | « PRESUBMIT.py ('k') | tests/revert_unittest.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/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_support.py and presubmit_canned_checks.py.""" 6 """Unit tests for presubmit_support.py and presubmit_canned_checks.py."""
7 7
8 import StringIO 8 import StringIO
9 9
10 import presubmit_support as presubmit 10 import presubmit_support as presubmit
(...skipping 716 matching lines...) Expand 10 before | Expand all | Expand 10 after
727 ( 727 (
728 [ 728 [
729 # To be tested. 729 # To be tested.
730 f('a/.git'), 730 f('a/.git'),
731 f('b.c/.git'), 731 f('b.c/.git'),
732 f('a/.git/bleh.py'), 732 f('a/.git/bleh.py'),
733 f('.git/bleh.py'), 733 f('.git/bleh.py'),
734 ], 734 ],
735 [ 735 [
736 # Expected. 736 # Expected.
737 'b.c/.git',
738 ], 737 ],
739 ), 738 ),
740 ] 739 ]
741 input_api = presubmit.InputApi(None, './PRESUBMIT.py', False) 740 input_api = presubmit.InputApi(None, './PRESUBMIT.py', False)
742 self.mox.ReplayAll() 741 self.mox.ReplayAll()
743 742
743 self.assertEqual(len(input_api.DEFAULT_WHITE_LIST), 20)
744 self.assertEqual(len(input_api.DEFAULT_BLACK_LIST), 9) 744 self.assertEqual(len(input_api.DEFAULT_BLACK_LIST), 9)
745 for item in files: 745 for item in files:
746 results = filter(input_api.FilterSourceFile, item[0]) 746 results = filter(input_api.FilterSourceFile, item[0])
747 for i in range(len(results)): 747 for i in range(len(results)):
748 self.assertEquals(results[i].LocalPath(), 748 self.assertEquals(results[i].LocalPath(),
749 presubmit.normpath(item[1][i])) 749 presubmit.normpath(item[1][i]))
750 # Same number of expected results. 750 # Same number of expected results.
751 self.assertEquals(len(results), len(item[1])) 751 self.assertEquals(sorted([f.LocalPath() for f in results]),
752 sorted(item[1]))
752 753
753 def testCustomFilter(self): 754 def testCustomFilter(self):
754 def FilterSourceFile(affected_file): 755 def FilterSourceFile(affected_file):
755 return 'a' in affected_file.LocalPath() 756 return 'a' in affected_file.LocalPath()
756 files = [('A', 'eeaee'), ('M', 'eeabee'), ('M', 'eebcee')] 757 files = [('A', 'eeaee'), ('M', 'eeabee'), ('M', 'eebcee')]
757 for (action, item) in files: 758 for (action, item) in files:
758 item = presubmit.os.path.join(self.fake_root_dir, item) 759 item = presubmit.os.path.join(self.fake_root_dir, item)
759 presubmit.os.path.exists(item).AndReturn(True) 760 presubmit.os.path.exists(item).AndReturn(True)
760 presubmit.os.path.isdir(item).AndReturn(False) 761 presubmit.os.path.isdir(item).AndReturn(False)
761 presubmit.scm.SVN.GetFileProperty(item, 'svn:mime-type').AndReturn(None) 762 presubmit.scm.SVN.GetFileProperty(item, 'svn:mime-type').AndReturn(None)
(...skipping 760 matching lines...) Expand 10 before | Expand all | Expand 10 after
1522 self.mox.ReplayAll() 1523 self.mox.ReplayAll()
1523 1524
1524 results = presubmit_canned_checks.RunPythonUnitTests( 1525 results = presubmit_canned_checks.RunPythonUnitTests(
1525 input_api, presubmit.OutputApi, ['test_module']) 1526 input_api, presubmit.OutputApi, ['test_module'])
1526 self.assertEquals(len(results), 0) 1527 self.assertEquals(len(results), 0)
1527 1528
1528 1529
1529 if __name__ == '__main__': 1530 if __name__ == '__main__':
1530 import unittest 1531 import unittest
1531 unittest.main() 1532 unittest.main()
OLDNEW
« no previous file with comments | « PRESUBMIT.py ('k') | tests/revert_unittest.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698