From 0d1bdeadb7f21631c3f7b798500028a98def5fed Mon Sep 17 00:00:00 2001 From: "dpranke@chromium.org" Date: Thu, 24 Mar 2011 22:54:38 +0000 Subject: [PATCH] fix a few minor lint and test issues. Note that presubmit_canned_checks should never import any modules directly but always access modules through input_api. Review URL: http://codereview.chromium.org/6676128 git-svn-id: svn://svn.chromium.org/chrome/trunk/tools/depot_tools@79337 0039d316-1c4b-4281-b951-d872f2087c98 --- presubmit_canned_checks.py | 4 +--- presubmit_support.py | 1 + tests/presubmit_unittest.py | 17 +++++++++-------- 3 files changed, 11 insertions(+), 11 deletions(-) diff --git a/presubmit_canned_checks.py b/presubmit_canned_checks.py index 25a3460212..5b54a5b9aa 100644 --- a/presubmit_canned_checks.py +++ b/presubmit_canned_checks.py @@ -4,8 +4,6 @@ """Generic presubmit checks that can be reused by other presubmit checks.""" -import time - ### Description checks @@ -761,7 +759,7 @@ def PanProjectChecks(input_api, output_api, r'can be\n' r'.*? found in the LICENSE file\.\n' ) % { - 'year': time.strftime('%Y'), + 'year': input_api.time.strftime('%Y'), 'project': project_name, } diff --git a/presubmit_support.py b/presubmit_support.py index f56ddd8aeb..e15b634f8a 100755 --- a/presubmit_support.py +++ b/presubmit_support.py @@ -257,6 +257,7 @@ class InputApi(object): self.re = re self.subprocess = subprocess self.tempfile = tempfile + self.time = time self.traceback = traceback self.unittest = unittest self.urllib2 = urllib2 diff --git a/tests/presubmit_unittest.py b/tests/presubmit_unittest.py index c7ad8191d2..1ecadb9c13 100755 --- a/tests/presubmit_unittest.py +++ b/tests/presubmit_unittest.py @@ -721,8 +721,8 @@ class InputApiUnittest(PresubmitTestsBase): 'basename', 'cPickle', 'cStringIO', 'canned_checks', 'change', 'environ', 'host_url', 'is_committing', 'json', 'marshal', 'os_path', 'owners_db', 'pickle', 'platform', 'python_executable', 're', - 'subprocess', 'tbr', 'tempfile', 'traceback', 'unittest', 'urllib2', - 'version', + 'subprocess', 'tbr', 'tempfile', 'time', 'traceback', 'unittest', + 'urllib2', 'version', ] # If this test fails, you should add the relevant test. self.compareMembers(presubmit.InputApi(self.fake_change, './.', False, @@ -1247,6 +1247,7 @@ class CannedChecksUnittest(PresubmitTestsBase): def testMembersChanged(self): self.mox.ReplayAll() members = [ + 'CheckBuildbotPendingBuilds', 'CheckChangeHasBugField', 'CheckChangeHasDescription', 'CheckChangeHasNoStrayWhitespace', 'CheckChangeHasOnlyOneEol', 'CheckChangeHasNoCR', @@ -1256,15 +1257,15 @@ class CannedChecksUnittest(PresubmitTestsBase): 'CheckChangeHasTestField', 'CheckChangeLintsClean', 'CheckChangeSvnEolStyle', - 'CheckLicense', - 'CheckSvnModifiedDirectories', - 'CheckSvnForCommonMimeTypes', 'CheckSvnProperty', 'CheckDoNotSubmit', 'CheckDoNotSubmitInDescription', 'CheckDoNotSubmitInFiles', - 'CheckLongLines', 'CheckTreeIsOpen', 'RunPythonUnitTests', - 'RunPylint', - 'CheckBuildbotPendingBuilds', 'CheckRietveldTryJobExecution', + 'CheckLongLines', 'CheckTreeIsOpen', 'PanProjectChecks', + 'CheckLicense', 'CheckOwners', + 'CheckRietveldTryJobExecution', + 'CheckSvnModifiedDirectories', + 'CheckSvnForCommonMimeTypes', 'CheckSvnProperty', + 'RunPythonUnitTests', 'RunPylint', ] # If this test fails, you should add the relevant test. self.compareMembers(presubmit_canned_checks, members)