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

Unified Diff: tests/patch_test.py

Issue 6877038: Improve patch handling and tests. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/tools/depot_tools
Patch Set: Created 9 years, 8 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
« no previous file with comments | « patch.py ('k') | tests/rietveld_test.py » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: tests/patch_test.py
diff --git a/tests/patch_test.py b/tests/patch_test.py
index b76c693d0d938fa26bc7e2557d39e1d628ee40f1..945d5d5e00c1fada2fccb08afade1477c19a3243 100755
--- a/tests/patch_test.py
+++ b/tests/patch_test.py
@@ -253,24 +253,6 @@ class PatchTest(unittest.TestCase):
except patch.UnsupportedPatchFormat:
pass
- def testInvalidFilePatchDiffSvn(self):
- try:
- patch.FilePatchDiff('svn_utils_test.txt', (
- '--- svn_utils_test.txt2\n'
- '+++ svn_utils_test.txt\n'
- '@@ -3,6 +3,7 @@ bb\n'
- 'ccc\n'
- 'dd\n'
- 'e\n'
- '+FOO!\n'
- 'ff\n'
- 'ggg\n'
- 'hh\n'),
- [])
- self.fail()
- except patch.UnsupportedPatchFormat:
- pass
-
def testValidSvn(self):
# pylint: disable=R0201
# Method could be a function
@@ -365,6 +347,52 @@ class PatchTest(unittest.TestCase):
patch.FilePatchDiff('foo', GIT_NEW, [])
self.assertTrue(True)
+ def testOnlyHeader(self):
+ p = patch.FilePatchDiff('file_a', '--- file_a\n+++ file_a\n', [])
+ self.assertTrue(p)
+
+ def testSmallest(self):
+ p = patch.FilePatchDiff(
+ 'file_a', '--- file_a\n+++ file_a\n@@ -0,0 +1 @@\n+foo\n', [])
+ self.assertTrue(p)
+
+ def testInverted(self):
+ try:
+ patch.FilePatchDiff(
+ 'file_a', '+++ file_a\n--- file_a\n@@ -0,0 +1 @@\n+foo\n', [])
+ self.fail()
+ except patch.UnsupportedPatchFormat:
+ pass
+
+ def testInvertedOnlyHeader(self):
+ try:
+ patch.FilePatchDiff('file_a', '+++ file_a\n--- file_a\n', [])
+ self.fail()
+ except patch.UnsupportedPatchFormat:
+ pass
+
+ def testRenameOnlyHeader(self):
+ p = patch.FilePatchDiff('file_b', '--- file_a\n+++ file_b\n', [])
+ self.assertTrue(p)
+
+ def testGitCopy(self):
+ diff = (
+ 'diff --git a/wtf b/wtf2\n'
+ 'similarity index 98%\n'
+ 'copy from wtf\n'
+ 'copy to wtf2\n'
+ 'index 79fbaf3..3560689 100755\n'
+ '--- a/wtf\n'
+ '+++ b/wtf2\n'
+ '@@ -1,4 +1,4 @@\n'
+ '-#!/usr/bin/env python\n'
+ '+#!/usr/bin/env python1.3\n'
+ ' # Copyright (c) 2010 The Chromium Authors. All rights reserved.\n'
+ ' # blah blah blah as\n'
+ ' # found in the LICENSE file.\n')
+ p = patch.FilePatchDiff('wtf2', diff, [])
+ self.assertTrue(p)
+
if __name__ == '__main__':
unittest.main()
« no previous file with comments | « patch.py ('k') | tests/rietveld_test.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698