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

Side by Side Diff: tests/patch_test.py

Issue 9387024: Fix unicode upgrade of patch. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/tools/depot_tools
Patch Set: Created 8 years, 10 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « patch.py ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 257 matching lines...) Expand 10 before | Expand all | Expand 10 after
268 def testSmallest(self): 268 def testSmallest(self):
269 p = patch.FilePatchDiff('file_a', RAW.NEW_NOT_NULL, []) 269 p = patch.FilePatchDiff('file_a', RAW.NEW_NOT_NULL, [])
270 self._check_patch(p, 'file_a', RAW.NEW_NOT_NULL, is_new=True, nb_hunks=1) 270 self._check_patch(p, 'file_a', RAW.NEW_NOT_NULL, is_new=True, nb_hunks=1)
271 271
272 def testRenameOnlyHeader(self): 272 def testRenameOnlyHeader(self):
273 p = patch.FilePatchDiff('file_b', RAW.MINIMAL_RENAME, []) 273 p = patch.FilePatchDiff('file_b', RAW.MINIMAL_RENAME, [])
274 self._check_patch( 274 self._check_patch(
275 p, 'file_b', RAW.MINIMAL_RENAME, source_filename='file_a', is_new=True, 275 p, 'file_b', RAW.MINIMAL_RENAME, source_filename='file_a', is_new=True,
276 nb_hunks=0) 276 nb_hunks=0)
277 277
278 def testUnicodeFilenameGet(self):
279 p = patch.FilePatchDiff(u'file_b', RAW.MINIMAL_RENAME, [])
cmp 2012/02/14 18:11:59 This string (u'file_b') can be both encoded and de
280 self.assertTrue(isinstance(p.get(False), str))
281 p.set_relpath('foo')
282 self.assertTrue(isinstance(p.get(False), str))
283
278 def testGitCopyPartial(self): 284 def testGitCopyPartial(self):
279 p = patch.FilePatchDiff('wtf2', GIT.COPY_PARTIAL, []) 285 p = patch.FilePatchDiff('wtf2', GIT.COPY_PARTIAL, [])
280 self._check_patch( 286 self._check_patch(
281 p, 'wtf2', GIT.COPY_PARTIAL, source_filename='wtf', is_git_diff=True, 287 p, 'wtf2', GIT.COPY_PARTIAL, source_filename='wtf', is_git_diff=True,
282 patchlevel=1, is_new=True, nb_hunks=1) 288 patchlevel=1, is_new=True, nb_hunks=1)
283 289
284 def testGitCopyPartialAsSvn(self): 290 def testGitCopyPartialAsSvn(self):
285 p = patch.FilePatchDiff('wtf2', GIT.COPY_PARTIAL, []) 291 p = patch.FilePatchDiff('wtf2', GIT.COPY_PARTIAL, [])
286 # TODO(maruel): Improve processing. 292 # TODO(maruel): Improve processing.
287 diff = ( 293 diff = (
(...skipping 210 matching lines...) Expand 10 before | Expand all | Expand 10 after
498 self.fail() 504 self.fail()
499 except patch.UnsupportedPatchFormat: 505 except patch.UnsupportedPatchFormat:
500 pass 506 pass
501 507
502 508
503 if __name__ == '__main__': 509 if __name__ == '__main__':
504 logging.basicConfig(level= 510 logging.basicConfig(level=
505 [logging.WARNING, logging.INFO, logging.DEBUG][ 511 [logging.WARNING, logging.INFO, logging.DEBUG][
506 min(2, sys.argv.count('-v'))]) 512 min(2, sys.argv.count('-v'))])
507 unittest.main() 513 unittest.main()
OLDNEW
« no previous file with comments | « patch.py ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698