~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/tests/test_annotate.py

  • Committer: Canonical.com Patch Queue Manager
  • Date: 2007-07-09 05:57:35 UTC
  • mfrom: (2593.2.1 ianc-integration)
  • Revision ID: pqm@pqm.ubuntu.com-20070709055735-nechlzumkvkl2woi
(Adeodato Simó) Merge annotate changes to make it behave in a non-ASCII world

Show diffs side-by-side

added added

removed removed

Lines of Context:
16
16
 
17
17
"""Whitebox tests for annotate functionality."""
18
18
 
 
19
import codecs
19
20
from cStringIO import StringIO
20
21
 
21
22
from bzrlib import (
301
302
                             'rev-1_1_1_1_1_1_1 | sixth\n',
302
303
                             sio.getvalue())
303
304
 
 
305
    def test_annotate_unicode_author(self):
 
306
        tree1 = self.make_branch_and_tree('tree1')
 
307
 
 
308
        self.build_tree_contents([('tree1/a', 'adi\xc3\xb3s')])
 
309
        tree1.add(['a'], ['a-id'])
 
310
        tree1.commit('a', rev_id='rev-1',
 
311
                     committer=u'Pepe P\xe9rez <pperez@ejemplo.com>',
 
312
                     timestamp=1166046000.00, timezone=0)
 
313
 
 
314
        self.build_tree_contents([('tree1/b', 'bye')])
 
315
        tree1.add(['b'], ['b-id'])
 
316
        tree1.commit('b', rev_id='rev-2',
 
317
                     committer=u'p\xe9rez',
 
318
                     timestamp=1166046000.00, timezone=0)
 
319
 
 
320
        # this passes if no exception is raised
 
321
        to_file = StringIO()
 
322
        annotate.annotate_file(tree1.branch, 'rev-1', 'a-id', to_file=to_file)
 
323
 
 
324
        sio = StringIO()
 
325
        to_file = codecs.getwriter('ascii')(sio)
 
326
        to_file.encoding = 'ascii' # codecs does not set it
 
327
        annotate.annotate_file(tree1.branch, 'rev-2', 'b-id', to_file=to_file)
 
328
        self.assertEqualDiff('2   p?rez   | bye\n', sio.getvalue())
 
329
 
 
330
        # test now with to_file.encoding = None
 
331
        to_file = tests.StringIOWrapper()
 
332
        to_file.encoding = None
 
333
        annotate.annotate_file(tree1.branch, 'rev-2', 'b-id', to_file=to_file)
 
334
        self.assertContainsRe('2   p.rez   | bye\n', to_file.getvalue())
 
335
 
 
336
        # and when it does not exist
 
337
        to_file = StringIO()
 
338
        annotate.annotate_file(tree1.branch, 'rev-2', 'b-id', to_file=to_file)
 
339
        self.assertContainsRe('2   p.rez   | bye\n', to_file.getvalue())
 
340
 
304
341
 
305
342
class TestReannotate(tests.TestCase):
306
343