| Index: tests/patch_test.py | 
| diff --git a/tests/patch_test.py b/tests/patch_test.py | 
| index db621ea51f88378eaedb17b37ed0587dcde15d3f..15d24abb68e100a354f9d60ce3593a06cbcff506 100755 | 
| --- a/tests/patch_test.py | 
| +++ b/tests/patch_test.py | 
| @@ -170,20 +170,10 @@ class PatchTest(unittest.TestCase): | 
| def testFilePatchDelete(self): | 
| p = patch.FilePatchDelete('foo', False) | 
| self._check_patch(p, 'foo', None, is_delete=True) | 
| -    try: | 
| -      p.get() | 
| -      self.fail() | 
| -    except NotImplementedError: | 
| -      pass | 
|  | 
| def testFilePatchDeleteBin(self): | 
| p = patch.FilePatchDelete('foo', True) | 
| self._check_patch(p, 'foo', None, is_delete=True, is_binary=True) | 
| -    try: | 
| -      p.get() | 
| -      self.fail() | 
| -    except NotImplementedError: | 
| -      pass | 
|  | 
| def testFilePatchBinary(self): | 
| p = patch.FilePatchBinary('foo', 'data', [], is_new=False) | 
| @@ -229,124 +219,6 @@ class PatchTest(unittest.TestCase): | 
| self._check_patch( | 
| p, 'foo', GIT_NEW, is_new=True, is_git_diff=True, patchlevel=1) | 
|  | 
| -  def testFilePatchDiffBad(self): | 
| -    try: | 
| -      patch.FilePatchDiff('foo', 'data', []) | 
| -      self.fail() | 
| -    except patch.UnsupportedPatchFormat: | 
| -      pass | 
| - | 
| -  def testFilePatchDiffEmpty(self): | 
| -    try: | 
| -      patch.FilePatchDiff('foo', '', []) | 
| -      self.fail() | 
| -    except patch.UnsupportedPatchFormat: | 
| -      pass | 
| - | 
| -  def testFilePatchDiffNone(self): | 
| -    try: | 
| -      patch.FilePatchDiff('foo', None, []) | 
| -      self.fail() | 
| -    except patch.UnsupportedPatchFormat: | 
| -      pass | 
| - | 
| -  def testFilePatchBadDiffName(self): | 
| -    try: | 
| -      patch.FilePatchDiff('foo', SVN_PATCH, []) | 
| -      self.fail() | 
| -    except patch.UnsupportedPatchFormat, e: | 
| -      self.assertEquals( | 
| -          "Can't process patch for file foo.\nUnexpected diff: chrome/file.cc.", | 
| -          str(e)) | 
| - | 
| -  def testFilePatchDiffBadHeader(self): | 
| -    try: | 
| -      diff = ( | 
| -        '+++ b/foo\n' | 
| -        '@@ -0,0 +1 @@\n' | 
| -        '+bar\n') | 
| -      patch.FilePatchDiff('foo', diff, []) | 
| -      self.fail() | 
| -    except patch.UnsupportedPatchFormat: | 
| -      pass | 
| - | 
| -  def testFilePatchDiffBadGitHeader(self): | 
| -    try: | 
| -      diff = ( | 
| -        'diff --git a/foo b/foo\n' | 
| -        '+++ b/foo\n' | 
| -        '@@ -0,0 +1 @@\n' | 
| -        '+bar\n') | 
| -      patch.FilePatchDiff('foo', diff, []) | 
| -      self.fail() | 
| -    except patch.UnsupportedPatchFormat: | 
| -      pass | 
| - | 
| -  def testFilePatchDiffBadHeaderReversed(self): | 
| -    try: | 
| -      diff = ( | 
| -        '+++ b/foo\n' | 
| -        '--- b/foo\n' | 
| -        '@@ -0,0 +1 @@\n' | 
| -        '+bar\n') | 
| -      patch.FilePatchDiff('foo', diff, []) | 
| -      self.fail() | 
| -    except patch.UnsupportedPatchFormat: | 
| -      pass | 
| - | 
| -  def testFilePatchDiffGitBadHeaderReversed(self): | 
| -    try: | 
| -      diff = ( | 
| -        'diff --git a/foo b/foo\n' | 
| -        '+++ b/foo\n' | 
| -        '--- b/foo\n' | 
| -        '@@ -0,0 +1 @@\n' | 
| -        '+bar\n') | 
| -      patch.FilePatchDiff('foo', diff, []) | 
| -      self.fail() | 
| -    except patch.UnsupportedPatchFormat: | 
| -      pass | 
| - | 
| -  def testFilePatchDiffInvalidGit(self): | 
| -    try: | 
| -      patch.FilePatchDiff('svn_utils_test.txt', ( | 
| -        'diff --git a/tests/svn_utils_test_data/svn_utils_test.txt ' | 
| -        'b/tests/svn_utils_test_data/svn_utils_test.txt\n' | 
| -        'index 0e4de76..8320059 100644\n' | 
| -        '--- a/svn_utils_test.txt\n' | 
| -        '+++ b/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 | 
| -    try: | 
| -      patch.FilePatchDiff('svn_utils_test2.txt', ( | 
| -        'diff --git a/svn_utils_test_data/svn_utils_test.txt ' | 
| -        'b/svn_utils_test.txt\n' | 
| -        'index 0e4de76..8320059 100644\n' | 
| -        '--- a/svn_utils_test.txt\n' | 
| -        '+++ b/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 | 
| @@ -412,17 +284,6 @@ class PatchTest(unittest.TestCase): | 
| header = ''.join(header) | 
| self.assertEquals(header, patches.patches[0].diff_header) | 
|  | 
| -  def testRelPathBad(self): | 
| -    patches = patch.PatchSet([ | 
| -        patch.FilePatchDiff('chrome\\file.cc', SVN_PATCH, []), | 
| -        patch.FilePatchDelete('other\\place\\foo', True), | 
| -    ]) | 
| -    try: | 
| -      patches.set_relpath('..') | 
| -      self.fail() | 
| -    except patch.UnsupportedPatchFormat: | 
| -      pass | 
| - | 
| def testRelPathEmpty(self): | 
| patches = patch.PatchSet([ | 
| patch.FilePatchDiff('chrome\\file.cc', SVN_PATCH, []), | 
| @@ -484,21 +345,6 @@ class PatchTest(unittest.TestCase): | 
| p = patch.FilePatchDiff('file_a', diff, []) | 
| self._check_patch(p, 'file_a', diff) | 
|  | 
| -  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): | 
| diff = '--- file_a\n+++ file_b\n' | 
| p = patch.FilePatchDiff('file_b', diff, []) | 
| @@ -552,6 +398,169 @@ class PatchTest(unittest.TestCase): | 
| p, 'natsort_test.py', diff, is_new=True, is_git_diff=True, patchlevel=1) | 
|  | 
|  | 
| +class PatchTestFail(unittest.TestCase): | 
| +  # All patches that should throw. | 
| +  def testFilePatchDelete(self): | 
| +    p = patch.FilePatchDelete('foo', False) | 
| +    try: | 
| +      p.get() | 
| +      self.fail() | 
| +    except NotImplementedError: | 
| +      pass | 
| + | 
| +  def testFilePatchDeleteBin(self): | 
| +    p = patch.FilePatchDelete('foo', True) | 
| +    try: | 
| +      p.get() | 
| +      self.fail() | 
| +    except NotImplementedError: | 
| +      pass | 
| + | 
| +  def testFilePatchDiffBad(self): | 
| +    try: | 
| +      patch.FilePatchDiff('foo', 'data', []) | 
| +      self.fail() | 
| +    except patch.UnsupportedPatchFormat: | 
| +      pass | 
| + | 
| +  def testFilePatchDiffEmpty(self): | 
| +    try: | 
| +      patch.FilePatchDiff('foo', '', []) | 
| +      self.fail() | 
| +    except patch.UnsupportedPatchFormat: | 
| +      pass | 
| + | 
| +  def testFilePatchDiffNone(self): | 
| +    try: | 
| +      patch.FilePatchDiff('foo', None, []) | 
| +      self.fail() | 
| +    except patch.UnsupportedPatchFormat: | 
| +      pass | 
| + | 
| +  def testFilePatchBadDiffName(self): | 
| +    try: | 
| +      patch.FilePatchDiff('foo', SVN_PATCH, []) | 
| +      self.fail() | 
| +    except patch.UnsupportedPatchFormat, e: | 
| +      self.assertEquals( | 
| +          "Can't process patch for file foo.\nUnexpected diff: chrome/file.cc.", | 
| +          str(e)) | 
| + | 
| +  def testFilePatchDiffBadHeader(self): | 
| +    try: | 
| +      diff = ( | 
| +        '+++ b/foo\n' | 
| +        '@@ -0,0 +1 @@\n' | 
| +        '+bar\n') | 
| +      patch.FilePatchDiff('foo', diff, []) | 
| +      self.fail() | 
| +    except patch.UnsupportedPatchFormat: | 
| +      pass | 
| + | 
| +  def testFilePatchDiffBadGitHeader(self): | 
| +    try: | 
| +      diff = ( | 
| +        'diff --git a/foo b/foo\n' | 
| +        '+++ b/foo\n' | 
| +        '@@ -0,0 +1 @@\n' | 
| +        '+bar\n') | 
| +      patch.FilePatchDiff('foo', diff, []) | 
| +      self.fail() | 
| +    except patch.UnsupportedPatchFormat: | 
| +      pass | 
| + | 
| +  def testFilePatchDiffBadHeaderReversed(self): | 
| +    try: | 
| +      diff = ( | 
| +        '+++ b/foo\n' | 
| +        '--- b/foo\n' | 
| +        '@@ -0,0 +1 @@\n' | 
| +        '+bar\n') | 
| +      patch.FilePatchDiff('foo', diff, []) | 
| +      self.fail() | 
| +    except patch.UnsupportedPatchFormat: | 
| +      pass | 
| + | 
| +  def testFilePatchDiffGitBadHeaderReversed(self): | 
| +    try: | 
| +      diff = ( | 
| +        'diff --git a/foo b/foo\n' | 
| +        '+++ b/foo\n' | 
| +        '--- b/foo\n' | 
| +        '@@ -0,0 +1 @@\n' | 
| +        '+bar\n') | 
| +      patch.FilePatchDiff('foo', diff, []) | 
| +      self.fail() | 
| +    except patch.UnsupportedPatchFormat: | 
| +      pass | 
| + | 
| +  def testFilePatchDiffInvalidGit(self): | 
| +    try: | 
| +      patch.FilePatchDiff('svn_utils_test.txt', ( | 
| +        'diff --git a/tests/svn_utils_test_data/svn_utils_test.txt ' | 
| +        'b/tests/svn_utils_test_data/svn_utils_test.txt\n' | 
| +        'index 0e4de76..8320059 100644\n' | 
| +        '--- a/svn_utils_test.txt\n' | 
| +        '+++ b/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 | 
| +    try: | 
| +      patch.FilePatchDiff('svn_utils_test2.txt', ( | 
| +        'diff --git a/svn_utils_test_data/svn_utils_test.txt ' | 
| +        'b/svn_utils_test.txt\n' | 
| +        'index 0e4de76..8320059 100644\n' | 
| +        '--- a/svn_utils_test.txt\n' | 
| +        '+++ b/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 testRelPathBad(self): | 
| +    patches = patch.PatchSet([ | 
| +        patch.FilePatchDiff('chrome\\file.cc', SVN_PATCH, []), | 
| +        patch.FilePatchDelete('other\\place\\foo', True), | 
| +    ]) | 
| +    try: | 
| +      patches.set_relpath('..') | 
| +      self.fail() | 
| +    except patch.UnsupportedPatchFormat: | 
| +      pass | 
| + | 
| +  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 | 
| + | 
| + | 
| if __name__ == '__main__': | 
| logging.basicConfig(level= | 
| [logging.WARNING, logging.INFO, logging.DEBUG][ | 
|  |