/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: Vincent Ladeuil
  • Date: 2010-01-25 17:48:22 UTC
  • mto: (4987.1.1 integration)
  • mto: This revision was merged to the branch mainline in revision 4988.
  • Revision ID: v.ladeuil+lp@free.fr-20100125174822-nce4l19sbwx83jvq
Deploying the new overrideAttr facility further reduces the complexity
and make the code clearer.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
# Copyright (C) 2005-2010 Canonical Ltd
 
1
# Copyright (C) 2005, 2006, 2007, 2008, 2009 Canonical Ltd
2
2
#
3
3
# This program is free software; you can redistribute it and/or modify
4
4
# it under the terms of the GNU General Public License as published by
29
29
    errors,
30
30
    trace,
31
31
    )
32
 
from bzrlib.tests import features, TestCaseInTempDir, TestCase
 
32
from bzrlib.tests import TestCaseInTempDir, TestCase
33
33
from bzrlib.trace import (
34
34
    mutter, mutter_callsite, report_exception,
35
35
    set_verbosity_level, get_verbosity_level, is_quiet, is_verbose, be_quiet,
36
36
    pop_log_file,
37
37
    push_log_file,
38
38
    _rollover_trace_maybe,
39
 
    show_error,
40
39
    )
41
40
 
42
41
 
104
103
        self.assertContainsRe(msg,
105
104
            r'^bzr: ERROR: \[Errno .*\] No such file.*nosuchfile')
106
105
 
107
 
    def test_format_pywintypes_error(self):
108
 
        self.requireFeature(features.pywintypes)
109
 
        import pywintypes, win32file
110
 
        try:
111
 
            win32file.RemoveDirectory('nosuchfile22222')
112
 
        except pywintypes.error:
113
 
            pass
114
 
        msg = _format_exception()
115
 
        # GZ 2010-05-03: Formatting for pywintypes.error is basic, a 3-tuple
116
 
        #                with errno, function name, and locale error message
117
 
        self.assertContainsRe(msg,
118
 
            r"^bzr: ERROR: \(2, 'RemoveDirectory[AW]?', .*\)")
119
 
 
120
106
    def test_format_unicode_error(self):
121
107
        try:
122
108
            raise errors.BzrCommandError(u'argument foo\xb5 does not exist')
229
215
        # have to do a replaceent here as well.
230
216
        self.assertContainsRe(log, "ascii argument: \xb5".decode('utf8',
231
217
            'replace'))
232
 
        
233
 
    def test_show_error(self):
234
 
        show_error('error1')
235
 
        show_error(u'error2 \xb5 blah')
236
 
        show_error('arg: %s', 'blah')
237
 
        show_error('arg2: %(key)s', {'key':'stuff'})
238
 
        try:
239
 
            raise Exception("oops")
240
 
        except:
241
 
            show_error('kwarg', exc_info=True)
242
 
        log = self.get_log()
243
 
        self.assertContainsRe(log, 'error1')
244
 
        self.assertContainsRe(log, u'error2 \xb5 blah')
245
 
        self.assertContainsRe(log, 'arg: blah')
246
 
        self.assertContainsRe(log, 'arg2: stuff')
247
 
        self.assertContainsRe(log, 'kwarg')
248
 
        self.assertContainsRe(log, 'Traceback \\(most recent call last\\):')
249
 
        self.assertContainsRe(log, 'File ".*test_trace.py", line .*, in test_show_error')
250
 
        self.assertContainsRe(log, 'raise Exception\\("oops"\\)')
251
 
        self.assertContainsRe(log, 'Exception: oops')
252
218
 
253
219
    def test_push_log_file(self):
254
220
        """Can push and pop log file, and this catches mutter messages.