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

Unified Diff: tests/presubmit_unittest.py

Issue 701683002: Revert of Added orphaned compiled Python file checks. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/tools/depot_tools
Patch Set: Created 6 years, 1 month 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
« no previous file with comments | « 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 39b64b828e0df40d925b85b0fca3bd65be81ba99..9df0b830e31d8e24b5bdaddf2095c5a042fffacc 100755
--- a/tests/presubmit_unittest.py
+++ b/tests/presubmit_unittest.py
@@ -7,9 +7,6 @@
# pylint: disable=E1101,E1103
-import __builtin__
-
-import contextlib
import functools
import itertools
import logging
@@ -180,8 +177,7 @@
'presubmit_canned_checks', 'random', 're', 'rietveld', 'scm',
'subprocess', 'sys', 'tempfile', 'time', 'traceback', 'types', 'unittest',
'urllib2', 'warn', 'multiprocessing', 'DoGetTryMasters',
- 'GetTryMastersExecuter', 'itertools', 'CleanOrphanedCompiledPython',
- 'IsCompiledPython',
+ 'GetTryMastersExecuter', 'itertools',
]
# If this test fails, you should add the relevant test.
self.compareMembers(presubmit, members)
@@ -686,7 +682,6 @@
presubmit.gclient_utils.FileRead(haspresubmit_path,
'rU').AndReturn(self.presubmit_text)
presubmit.random.randint(0, 4).AndReturn(1)
- presubmit.os.walk(self.fake_root_dir).AndReturn([])
self.mox.ReplayAll()
input_buf = StringIO.StringIO('y\n')
@@ -727,8 +722,6 @@
).AndReturn(self.presubmit_text)
presubmit.random.randint(0, 4).AndReturn(1)
presubmit.random.randint(0, 4).AndReturn(1)
- presubmit.os.walk(self.fake_root_dir).AndReturn([])
- presubmit.os.walk(self.fake_root_dir).AndReturn([])
self.mox.ReplayAll()
input_buf = StringIO.StringIO('n\n') # say no to the warning
@@ -775,7 +768,6 @@
presubmit.gclient_utils.FileRead(haspresubmit_path, 'rU').AndReturn(
self.presubmit_text)
presubmit.random.randint(0, 4).AndReturn(1)
- presubmit.os.walk(self.fake_root_dir).AndReturn([])
self.mox.ReplayAll()
change = presubmit.Change(
@@ -817,7 +809,6 @@
'haspresubmit',
'PRESUBMIT.py')).AndReturn(False)
presubmit.random.randint(0, 4).AndReturn(0)
- presubmit.os.walk(self.fake_root_dir).AndReturn([])
self.mox.ReplayAll()
input_buf = StringIO.StringIO('y\n')
@@ -900,7 +891,6 @@
inherit_path = presubmit.os.path.join(self.fake_root_dir,
self._INHERIT_SETTINGS)
presubmit.os.path.isfile(inherit_path).AndReturn(False)
- presubmit.os.walk(self.fake_root_dir).AndReturn([])
self.mox.ReplayAll()
output = StringIO.StringIO()
@@ -1184,88 +1174,6 @@
self.fail()
except SystemExit, e:
self.assertEquals(2, e.code)
-
- def testOrphanedCompiledPythonDoesntRemoveFiles(self):
- self.mox.StubOutWithMock(presubmit, 'IsCompiledPython')
- py_path = os.path.join(self.fake_root_dir, 'myfile.py')
- pyc_path = os.path.join(self.fake_root_dir, 'myfile.pyc')
-
- presubmit.os.walk(self.fake_root_dir).AndReturn([
- (self.fake_root_dir, [], ['myfile.pyc']),
- ])
- presubmit.os.path.isfile(py_path).AndReturn(False)
- presubmit.IsCompiledPython(pyc_path).AndReturn(True)
- self.mox.ReplayAll()
-
- output = StringIO.StringIO()
- presubmit.CleanOrphanedCompiledPython(output, self.fake_root_dir, False)
-
- def testCleanOrphanedCompiledPython(self):
- self.mox.StubOutWithMock(presubmit, 'IsCompiledPython')
- py_path = os.path.join(self.fake_root_dir, 'myfile.py')
- pyc_path = os.path.join(self.fake_root_dir, 'myfile.pyc')
-
- presubmit.os.walk(self.fake_root_dir).AndReturn([
- (self.fake_root_dir, [], ['myfile.pyc']),
- ])
- presubmit.os.path.isfile(py_path).AndReturn(False)
- presubmit.IsCompiledPython(pyc_path).AndReturn(True)
- presubmit.os.remove(pyc_path)
- self.mox.ReplayAll()
-
- output = StringIO.StringIO()
- presubmit.CleanOrphanedCompiledPython(output, self.fake_root_dir, True)
-
- def testCleanNonOrphanedCompiledPython(self):
- self.mox.StubOutWithMock(presubmit, 'IsCompiledPython')
- py_path = os.path.join(self.fake_root_dir, 'myfile.py')
-
- presubmit.os.walk(self.fake_root_dir).AndReturn([
- (self.fake_root_dir, [], ['myfile.pyc', 'myfile.py']),
- ])
- presubmit.os.path.isfile(py_path).AndReturn(True)
- self.mox.ReplayAll()
-
- output = StringIO.StringIO()
- presubmit.CleanOrphanedCompiledPython(output, self.fake_root_dir, True)
-
- def testCleanOrphanedCompiledPythonAvoidsOtherFiles(self):
- self.mox.StubOutWithMock(presubmit, 'IsCompiledPython')
-
- presubmit.os.walk(self.fake_root_dir).AndReturn([
- (self.fake_root_dir, [], ['otherfile.txt']),
- ])
- self.mox.ReplayAll()
-
- output = StringIO.StringIO()
- presubmit.CleanOrphanedCompiledPython(output, self.fake_root_dir, True)
-
- def testIsCompiledPython(self):
- self.mox.StubOutWithMock(__builtin__, 'open')
- pyc_path = os.path.join(self.fake_root_dir, 'testfile.pyc')
- open(pyc_path, 'rb').AndReturn(contextlib.closing(
- StringIO.StringIO('\x00\x00\x0d\x0a\x00\x00\x00\x00')))
- self.mox.ReplayAll()
-
- self.assertTrue(presubmit.IsCompiledPython(pyc_path))
-
- def testIsCompiledPythonFailsForInvalidMagic(self):
- self.mox.StubOutWithMock(__builtin__, 'open')
- pyc_path = os.path.join(self.fake_root_dir, 'testfile.pyc')
- open(pyc_path, 'rb').AndReturn(contextlib.closing(
- StringIO.StringIO('\xca\xfe\xba\xbe\x00\x00\x00\x00')))
- self.mox.ReplayAll()
-
- self.assertFalse(presubmit.IsCompiledPython(pyc_path))
-
- def testIsCompiledPythonFailsForInvalidSize(self):
- self.mox.StubOutWithMock(__builtin__, 'open')
- pyc_path = os.path.join(self.fake_root_dir, 'testfile.pyc')
- open(pyc_path, 'rb').AndReturn(contextlib.closing(
- StringIO.StringIO('\x00\x00\x0d\x0a\x00\x00\x00')))
- self.mox.ReplayAll()
-
- self.assertFalse(presubmit.IsCompiledPython(pyc_path))
class InputApiUnittest(PresubmitTestsBase):
« no previous file with comments | « presubmit_support.py ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698