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

Side by Side Diff: tests/presubmit_unittest.py

Issue 802403003: presubmit_unittest: Fix pylint errors. (Closed) Base URL: https://chromium.googlesource.com/chromium/tools/depot_tools.git@master
Patch Set: Created 6 years 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 | « no previous file | no next file » | 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) 2012 The Chromium Authors. All rights reserved. 2 # Copyright (c) 2012 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: disable=E1101,E1103 8 # pylint: disable=E1101,E1103
9 9
10 import functools 10 import functools
(...skipping 1982 matching lines...) Expand 10 before | Expand all | Expand 10 after
1993 change1 = presubmit.SvnChange( 1993 change1 = presubmit.SvnChange(
1994 'mychange', '', self.fake_root_dir, [], 0, 0, None) 1994 'mychange', '', self.fake_root_dir, [], 0, 0, None)
1995 input_api1 = self.MockInputApi(change1, committing) 1995 input_api1 = self.MockInputApi(change1, committing)
1996 files1 = [ 1996 files1 = [
1997 presubmit.SvnAffectedFile('foo/bar.cc', 'A', self.fake_root_dir, None), 1997 presubmit.SvnAffectedFile('foo/bar.cc', 'A', self.fake_root_dir, None),
1998 presubmit.SvnAffectedFile('foo.cc', 'M', self.fake_root_dir, None), 1998 presubmit.SvnAffectedFile('foo.cc', 'M', self.fake_root_dir, None),
1999 ] 1999 ]
2000 if use_source_file: 2000 if use_source_file:
2001 input_api1.AffectedSourceFiles(None).AndReturn(files1) 2001 input_api1.AffectedSourceFiles(None).AndReturn(files1)
2002 else: 2002 else:
2003 input_api1.AffectedFiles(include_deleted=False).AndReturn(files1) 2003 input_api1.AffectedFiles(include_deletes=False).AndReturn(files1)
2004 presubmit.scm.SVN.GetFileProperty( 2004 presubmit.scm.SVN.GetFileProperty(
2005 presubmit.normpath('foo/bar.cc'), property_name, self.fake_root_dir 2005 presubmit.normpath('foo/bar.cc'), property_name, self.fake_root_dir
2006 ).AndReturn(value1) 2006 ).AndReturn(value1)
2007 presubmit.scm.SVN.GetFileProperty( 2007 presubmit.scm.SVN.GetFileProperty(
2008 presubmit.normpath('foo.cc'), property_name, self.fake_root_dir 2008 presubmit.normpath('foo.cc'), property_name, self.fake_root_dir
2009 ).AndReturn(value1) 2009 ).AndReturn(value1)
2010 change2 = presubmit.SvnChange( 2010 change2 = presubmit.SvnChange(
2011 'mychange', '', self.fake_root_dir, [], 0, 0, None) 2011 'mychange', '', self.fake_root_dir, [], 0, 0, None)
2012 input_api2 = self.MockInputApi(change2, committing) 2012 input_api2 = self.MockInputApi(change2, committing)
2013 files2 = [ 2013 files2 = [
2014 presubmit.SvnAffectedFile('foo/bar.cc', 'A', self.fake_root_dir, None), 2014 presubmit.SvnAffectedFile('foo/bar.cc', 'A', self.fake_root_dir, None),
2015 presubmit.SvnAffectedFile('foo.cc', 'M', self.fake_root_dir, None), 2015 presubmit.SvnAffectedFile('foo.cc', 'M', self.fake_root_dir, None),
2016 ] 2016 ]
2017 if use_source_file: 2017 if use_source_file:
2018 input_api2.AffectedSourceFiles(None).AndReturn(files2) 2018 input_api2.AffectedSourceFiles(None).AndReturn(files2)
2019 else: 2019 else:
2020 input_api2.AffectedFiles(include_deleted=False).AndReturn(files2) 2020 input_api2.AffectedFiles(include_deletes=False).AndReturn(files2)
2021 2021
2022 presubmit.scm.SVN.GetFileProperty( 2022 presubmit.scm.SVN.GetFileProperty(
2023 presubmit.normpath('foo/bar.cc'), property_name, self.fake_root_dir 2023 presubmit.normpath('foo/bar.cc'), property_name, self.fake_root_dir
2024 ).AndReturn(value2) 2024 ).AndReturn(value2)
2025 presubmit.scm.SVN.GetFileProperty( 2025 presubmit.scm.SVN.GetFileProperty(
2026 presubmit.normpath('foo.cc'), property_name, self.fake_root_dir 2026 presubmit.normpath('foo.cc'), property_name, self.fake_root_dir
2027 ).AndReturn(value2) 2027 ).AndReturn(value2)
2028 self.mox.ReplayAll() 2028 self.mox.ReplayAll()
2029 2029
2030 results1 = check(input_api1, presubmit.OutputApi, None) 2030 results1 = check(input_api1, presubmit.OutputApi, None)
(...skipping 137 matching lines...) Expand 10 before | Expand all | Expand 10 after
2168 affected_file1.LocalPath().AndReturn('foo.cc') 2168 affected_file1.LocalPath().AndReturn('foo.cc')
2169 affected_file1.NewContents().AndReturn(['yo, ']) 2169 affected_file1.NewContents().AndReturn(['yo, '])
2170 affected_file4.LocalPath().AndReturn('makefile.foo') 2170 affected_file4.LocalPath().AndReturn('makefile.foo')
2171 affected_file4.LocalPath().AndReturn('makefile.foo') 2171 affected_file4.LocalPath().AndReturn('makefile.foo')
2172 affected_file4.NewContents().AndReturn(['ye\t']) 2172 affected_file4.NewContents().AndReturn(['ye\t'])
2173 affected_file4.ChangedContents().AndReturn([(46, 'ye\t')]) 2173 affected_file4.ChangedContents().AndReturn([(46, 'ye\t')])
2174 affected_file4.LocalPath().AndReturn('makefile.foo') 2174 affected_file4.LocalPath().AndReturn('makefile.foo')
2175 affected_files = (affected_file1, affected_file2, 2175 affected_files = (affected_file1, affected_file2,
2176 affected_file3, affected_file4) 2176 affected_file3, affected_file4)
2177 2177
2178 def test(file_filter, include_deletes): 2178 def test(include_dirs=False, include_deletes=True, file_filter=None):
2179 self.assertFalse(include_deletes) 2179 self.assertFalse(include_deletes)
2180 for x in affected_files: 2180 for x in affected_files:
2181 if file_filter(x): 2181 if file_filter(x):
2182 yield x 2182 yield x
2183 # Override the mock of these functions. 2183 # Override the mock of these functions.
2184 input_api1.FilterSourceFile = lambda x: x 2184 input_api1.FilterSourceFile = lambda x: x
2185 input_api1.AffectedFiles = test 2185 input_api1.AffectedFiles = test
2186 self.mox.ReplayAll() 2186 self.mox.ReplayAll()
2187 2187
2188 results1 = presubmit_canned_checks.CheckChangeHasNoTabs(input_api1, 2188 results1 = presubmit_canned_checks.CheckChangeHasNoTabs(input_api1,
(...skipping 732 matching lines...) Expand 10 before | Expand all | Expand 10 after
2921 owners_check=False) 2921 owners_check=False)
2922 self.assertEqual(1, len(results)) 2922 self.assertEqual(1, len(results))
2923 self.assertEqual( 2923 self.assertEqual(
2924 'Found line ending with white spaces in:', results[0]._message) 2924 'Found line ending with white spaces in:', results[0]._message)
2925 self.checkstdout('') 2925 self.checkstdout('')
2926 2926
2927 2927
2928 if __name__ == '__main__': 2928 if __name__ == '__main__':
2929 import unittest 2929 import unittest
2930 unittest.main() 2930 unittest.main()
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698