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

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: Add more test 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 | « testing_support/patches_data.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 # coding: utf-8
2 # Copyright (c) 2012 The Chromium Authors. All rights reserved. 3 # 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 4 # Use of this source code is governed by a BSD-style license that can be
4 # found in the LICENSE file. 5 # found in the LICENSE file.
5 6
6 """Unit tests for patch.py.""" 7 """Unit tests for patch.py."""
7 8
8 import logging 9 import logging
9 import os 10 import os
10 import posixpath 11 import posixpath
11 import sys 12 import sys
(...skipping 256 matching lines...) Expand 10 before | Expand all | Expand 10 after
268 def testSmallest(self): 269 def testSmallest(self):
269 p = patch.FilePatchDiff('file_a', RAW.NEW_NOT_NULL, []) 270 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) 271 self._check_patch(p, 'file_a', RAW.NEW_NOT_NULL, is_new=True, nb_hunks=1)
271 272
272 def testRenameOnlyHeader(self): 273 def testRenameOnlyHeader(self):
273 p = patch.FilePatchDiff('file_b', RAW.MINIMAL_RENAME, []) 274 p = patch.FilePatchDiff('file_b', RAW.MINIMAL_RENAME, [])
274 self._check_patch( 275 self._check_patch(
275 p, 'file_b', RAW.MINIMAL_RENAME, source_filename='file_a', is_new=True, 276 p, 'file_b', RAW.MINIMAL_RENAME, source_filename='file_a', is_new=True,
276 nb_hunks=0) 277 nb_hunks=0)
277 278
279 def testUnicodeFilenameGet(self):
280 p = patch.FilePatchDiff(u'filé_b', RAW.RENAME_UTF8, [])
281 self._check_patch(
282 p, u'filé_b', RAW.RENAME_UTF8, source_filename=u'file_à', is_new=True,
283 nb_hunks=1)
284 self.assertTrue(isinstance(p.get(False), str))
285 p.set_relpath('foo')
286 self.assertTrue(isinstance(p.get(False), str))
287 self.assertEquals(u'foo/file_à'.encode('utf-8'), p.source_filename_utf8)
288 self.assertEquals(u'foo/file_à', p.source_filename)
289 self.assertEquals(u'foo/filé_b'.encode('utf-8'), p.filename_utf8)
290 self.assertEquals(u'foo/filé_b', p.filename)
291
278 def testGitCopyPartial(self): 292 def testGitCopyPartial(self):
279 p = patch.FilePatchDiff('wtf2', GIT.COPY_PARTIAL, []) 293 p = patch.FilePatchDiff('wtf2', GIT.COPY_PARTIAL, [])
280 self._check_patch( 294 self._check_patch(
281 p, 'wtf2', GIT.COPY_PARTIAL, source_filename='wtf', is_git_diff=True, 295 p, 'wtf2', GIT.COPY_PARTIAL, source_filename='wtf', is_git_diff=True,
282 patchlevel=1, is_new=True, nb_hunks=1) 296 patchlevel=1, is_new=True, nb_hunks=1)
283 297
284 def testGitCopyPartialAsSvn(self): 298 def testGitCopyPartialAsSvn(self):
285 p = patch.FilePatchDiff('wtf2', GIT.COPY_PARTIAL, []) 299 p = patch.FilePatchDiff('wtf2', GIT.COPY_PARTIAL, [])
286 # TODO(maruel): Improve processing. 300 # TODO(maruel): Improve processing.
287 diff = ( 301 diff = (
(...skipping 210 matching lines...) Expand 10 before | Expand all | Expand 10 after
498 self.fail() 512 self.fail()
499 except patch.UnsupportedPatchFormat: 513 except patch.UnsupportedPatchFormat:
500 pass 514 pass
501 515
502 516
503 if __name__ == '__main__': 517 if __name__ == '__main__':
504 logging.basicConfig(level= 518 logging.basicConfig(level=
505 [logging.WARNING, logging.INFO, logging.DEBUG][ 519 [logging.WARNING, logging.INFO, logging.DEBUG][
506 min(2, sys.argv.count('-v'))]) 520 min(2, sys.argv.count('-v'))])
507 unittest.main() 521 unittest.main()
OLDNEW
« no previous file with comments | « testing_support/patches_data.py ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698