| OLD | NEW |
| 1 #!/usr/bin/env python | 1 #!/usr/bin/env python |
| 2 # Copyright (c) 2012 The Chromium Authors. All rights reserved. | 2 # Copyright (c) 2012 The Chromium Authors. All rights reserved. |
| 3 # Use of this source code is governed by a BSD-style license that can be | 3 # Use of this source code is governed by a BSD-style license that can be |
| 4 # found in the LICENSE file. | 4 # found in the LICENSE file. |
| 5 | 5 |
| 6 """Unit tests for patch.py.""" | 6 """Unit tests for patch.py.""" |
| 7 | 7 |
| 8 import logging | 8 import logging |
| 9 import os | 9 import os |
| 10 import posixpath | 10 import posixpath |
| (...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 64 self._check_patch(p, 'foo', 'data', is_binary=True) | 64 self._check_patch(p, 'foo', 'data', is_binary=True) |
| 65 | 65 |
| 66 def testFilePatchBinaryNew(self): | 66 def testFilePatchBinaryNew(self): |
| 67 p = patch.FilePatchBinary('foo', 'data', [], is_new=True) | 67 p = patch.FilePatchBinary('foo', 'data', [], is_new=True) |
| 68 self._check_patch(p, 'foo', 'data', is_binary=True, is_new=True) | 68 self._check_patch(p, 'foo', 'data', is_binary=True, is_new=True) |
| 69 | 69 |
| 70 def testFilePatchDiff(self): | 70 def testFilePatchDiff(self): |
| 71 p = patch.FilePatchDiff('chrome/file.cc', RAW.PATCH, []) | 71 p = patch.FilePatchDiff('chrome/file.cc', RAW.PATCH, []) |
| 72 self._check_patch(p, 'chrome/file.cc', RAW.PATCH, nb_hunks=1) | 72 self._check_patch(p, 'chrome/file.cc', RAW.PATCH, nb_hunks=1) |
| 73 | 73 |
| 74 def testDifferent(self): |
| 75 name = 'master/unittests/data/processes-summary.dat' |
| 76 p = patch.FilePatchDiff(name, RAW.DIFFERENT, []) |
| 77 self._check_patch(p, name, RAW.DIFFERENT, nb_hunks=1) |
| 78 |
| 74 def testFilePatchDiffHeaderMode(self): | 79 def testFilePatchDiffHeaderMode(self): |
| 75 p = patch.FilePatchDiff('git_cl/git-cl', GIT.MODE_EXE, []) | 80 p = patch.FilePatchDiff('git_cl/git-cl', GIT.MODE_EXE, []) |
| 76 self._check_patch( | 81 self._check_patch( |
| 77 p, 'git_cl/git-cl', GIT.MODE_EXE, is_git_diff=True, patchlevel=1, | 82 p, 'git_cl/git-cl', GIT.MODE_EXE, is_git_diff=True, patchlevel=1, |
| 78 svn_properties=[('svn:executable', '*')], nb_hunks=0) | 83 svn_properties=[('svn:executable', '*')], nb_hunks=0) |
| 79 | 84 |
| 80 def testFilePatchDiffHeaderModeIndex(self): | 85 def testFilePatchDiffHeaderModeIndex(self): |
| 81 p = patch.FilePatchDiff('git_cl/git-cl', GIT.MODE_EXE_JUNK, []) | 86 p = patch.FilePatchDiff('git_cl/git-cl', GIT.MODE_EXE_JUNK, []) |
| 82 self._check_patch( | 87 self._check_patch( |
| 83 p, 'git_cl/git-cl', GIT.MODE_EXE_JUNK, is_git_diff=True, patchlevel=1, | 88 p, 'git_cl/git-cl', GIT.MODE_EXE_JUNK, is_git_diff=True, patchlevel=1, |
| (...skipping 409 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 493 self.fail() | 498 self.fail() |
| 494 except patch.UnsupportedPatchFormat: | 499 except patch.UnsupportedPatchFormat: |
| 495 pass | 500 pass |
| 496 | 501 |
| 497 | 502 |
| 498 if __name__ == '__main__': | 503 if __name__ == '__main__': |
| 499 logging.basicConfig(level= | 504 logging.basicConfig(level= |
| 500 [logging.WARNING, logging.INFO, logging.DEBUG][ | 505 [logging.WARNING, logging.INFO, logging.DEBUG][ |
| 501 min(2, sys.argv.count('-v'))]) | 506 min(2, sys.argv.count('-v'))]) |
| 502 unittest.main() | 507 unittest.main() |
| OLD | NEW |