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

Unified Diff: tests/presubmit_unittest.py

Issue 113933: Add AffectedFile.IsTextFile() and deprecate AffectedTextFiles(). (Closed)
Patch Set: Stop using return InputApi._RightHandSideLinesImpl( Created 11 years, 7 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 side-by-side diff with in-line comments
Download patch
« presubmit_support.py ('K') | « presubmit_support.py ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: tests/presubmit_unittest.py
diff --git a/tests/presubmit_unittest.py b/tests/presubmit_unittest.py
index 6b987c46b9f1ca08b4ca8eb65a1a904679e67772..7f5d57191cbe0fdb953150916445746552226065 100755
--- a/tests/presubmit_unittest.py
+++ b/tests/presubmit_unittest.py
@@ -9,6 +9,7 @@ import os
import StringIO
import sys
import unittest
+import warnings
# Local imports
import gcl
@@ -20,6 +21,8 @@ import presubmit_canned_checks
class PresubmitTestsBase(unittest.TestCase):
"""Setups and tear downs the mocks but doesn't test anything as-is."""
def setUp(self):
+ self._warnings_stack = warnings.catch_warnings()
+ warnings.simplefilter("ignore", DeprecationWarning)
self.original_IsFile = os.path.isfile
def MockIsFile(f):
dir = os.path.dirname(f)
@@ -92,6 +95,7 @@ def CheckChangeOnUpload(input_api, output_api):
gcl.ReadFile = self.original_ReadFile
gcl.GetRepositoryRoot = self.original_GetRepositoryRoot
sys.stdout = self._sys_stdout
+ self._warnings_stack = None
@staticmethod
def MakeBasicChange(name, description):
@@ -117,10 +121,11 @@ class PresubmitUnittest(PresubmitTestsBase):
'AffectedFile', 'DoPresubmitChecks', 'GclChange', 'InputApi',
'ListRelevantPresubmitFiles', 'Main', 'NotImplementedException',
'OutputApi', 'ParseFiles', 'PresubmitExecuter',
- 'ScanSubDirs', 'SvnAffectedFile', 'cPickle', 'cStringIO', 'exceptions',
+ 'ScanSubDirs', 'SvnAffectedFile',
+ 'cPickle', 'cStringIO', 'deprecated', 'exceptions',
'fnmatch', 'gcl', 'gclient', 'glob', 'marshal', 'normpath', 'optparse',
'os', 'pickle', 'presubmit_canned_checks', 're', 'subprocess', 'sys',
- 'tempfile', 'types', 'urllib2',
+ 'tempfile', 'types', 'urllib2', 'warnings',
]
# If this test fails, you should add the relevant test.
self.compareMembers(presubmit, members)
@@ -449,15 +454,16 @@ class InputApiUnittest(PresubmitTestsBase):
self.compareMembers(presubmit.InputApi(None, './.'), members)
def testDepotToLocalPath(self):
- path = presubmit.InputApi.DepotToLocalPath('svn:/foo/smurf')
+ path = presubmit.InputApi(None, './p').DepotToLocalPath('svn:/foo/smurf')
self.failUnless(path == 'smurf')
- path = presubmit.InputApi.DepotToLocalPath('svn:/foo/notfound/burp')
+ path = presubmit.InputApi(None, './p').DepotToLocalPath(
+ 'svn:/foo/notfound/burp')
self.failUnless(path == None)
def testLocalToDepotPath(self):
- path = presubmit.InputApi.LocalToDepotPath('smurf')
+ path = presubmit.InputApi(None, './p').LocalToDepotPath('smurf')
self.failUnless(path == 'svn:/foo/smurf')
- path = presubmit.InputApi.LocalToDepotPath('notfound-food')
+ path = presubmit.InputApi(None, './p').LocalToDepotPath('notfound-food')
self.failUnless(path == None)
def testInputApiConstruction(self):
@@ -524,7 +530,7 @@ class InputApiUnittest(PresubmitTestsBase):
for line in api.RightHandSideLines():
rhs_lines.append(line)
self.failUnless(len(rhs_lines) == 2)
- self.failUnless(rhs_lines[0][0].LocalPath() ==
+ self.assertEqual(rhs_lines[0][0].LocalPath(),
presubmit.normpath('foo/blat.cc'))
def testGetAbsoluteLocalPath(self):
@@ -623,7 +629,8 @@ class OuputApiUnittest(PresubmitTestsBase):
class AffectedFileUnittest(PresubmitTestsBase):
def testMembersChanged(self):
members = [
- 'AbsoluteLocalPath', 'Action', 'IsDirectory', 'LocalPath', 'NewContents',
+ 'AbsoluteLocalPath', 'Action', 'IsDirectory', 'IsTextFile',
+ 'LocalPath', 'NewContents',
'OldContents', 'OldFileTempPath', 'Property', 'ServerPath', 'action',
'is_directory', 'path', 'properties', 'repository_root', 'server_path',
]
« presubmit_support.py ('K') | « presubmit_support.py ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698