/brz/remove-bazaar

To get this branch, use:
bzr branch http://gegoxaren.bato24.eu/bzr/brz/remove-bazaar

« back to all changes in this revision

Viewing changes to bzrlib/tests/test_trace.py

  • Committer: Carl Friedrich Bolz
  • Date: 2006-09-06 21:17:22 UTC
  • mfrom: (1977 +trunk)
  • mto: This revision was merged to the branch mainline in revision 2026.
  • Revision ID: cfbolz@gmx.de-20060906211722-b04f9c3ad1f53ef1
Merge bzr.dev.

Show diffs side-by-side

added added

removed removed

Lines of Context:
18
18
 
19
19
"""Tests for trace library"""
20
20
 
 
21
from cStringIO import StringIO
21
22
import errno
22
23
import os
23
24
import sys
24
 
from StringIO import StringIO
25
25
 
 
26
from bzrlib import (
 
27
    errors,
 
28
    )
26
29
from bzrlib.tests import TestCaseInTempDir, TestCase
27
30
from bzrlib.trace import mutter, report_exception
28
 
from bzrlib.errors import NotBranchError
29
31
 
30
32
 
31
33
def _format_exception():
66
68
        msg = _format_exception()
67
69
        self.assertContainsRe(msg, r'^bzr: ERROR: \[Errno .*\] No such file.*nosuchfile')
68
70
 
 
71
    def test_format_unicode_error(self):
 
72
        try:
 
73
            raise errors.BzrCommandError(u'argument foo\xb5 does not exist')
 
74
        except errors.BzrCommandError:
 
75
            pass
 
76
        msg = _format_exception()
69
77
 
70
78
    def test_format_exception(self):
71
79
        """Short formatting of bzr exceptions"""
72
80
        try:
73
 
            raise NotBranchError, 'wibble'
74
 
        except NotBranchError:
 
81
            raise errors.NotBranchError, 'wibble'
 
82
        except errors.NotBranchError:
75
83
            pass
76
84
        msg = _format_exception()
77
85
        self.assertTrue(len(msg) > 0)
82
90
        self.log(u'the unicode character for benzene is \N{BENZENE RING}')
83
91
        self.assertContainsRe(self._get_log(keep_log_file=True),
84
92
                              "the unicode character for benzene is")
 
93
    
 
94
    def test_trace_argument_unicode(self):
 
95
        """Write a Unicode argument to the trace log"""
 
96
        mutter(u'the unicode character for benzene is %s', u'\N{BENZENE RING}')
 
97
        self.assertContainsRe(self._get_log(keep_log_file=True),
 
98
                              'the unicode character')
 
99
 
 
100
    def test_trace_argument_utf8(self):
 
101
        """Write a Unicode argument to the trace log"""
 
102
        mutter(u'the unicode character for benzene is %s',
 
103
               u'\N{BENZENE RING}'.encode('utf-8'))
 
104
        self.assertContainsRe(self._get_log(keep_log_file=True),
 
105
                              'the unicode character')
85
106
 
86
107
    def test_report_broken_pipe(self):
87
108
        try:
97
118
        # raise an exception
98
119
        mutter(u'Writing a greek mu (\xb5) works in a unicode string')
99
120
        mutter('But fails in an ascii string \xb5')
 
121
        mutter('and in an ascii argument: %s', '\xb5')
100
122
        log = self._get_log(keep_log_file=True)
101
123
        self.assertContainsRe(log, 'Writing a greek mu')
102
 
        self.assertContainsRe(log, 'UnicodeError')
103
 
        self.assertContainsRe(log, "'But fails in an ascii string")
 
124
        self.assertContainsRe(log, "But fails in an ascii string")
 
125
        self.assertContainsRe(log, u"ascii argument: \xb5")