~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/tests/test_trace.py

  • Committer: Martin Pool
  • Date: 2010-04-21 11:27:04 UTC
  • mto: This revision was merged to the branch mainline in revision 5189.
  • Revision ID: mbp@canonical.com-20100421112704-zijso22b6pdevrxy
Simplify various code to use user_url

Show diffs side-by-side

added added

removed removed

Lines of Context:
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,
104
104
        self.assertContainsRe(msg,
105
105
            r'^bzr: ERROR: \[Errno .*\] No such file.*nosuchfile')
106
106
 
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
107
    def test_format_unicode_error(self):
121
108
        try:
122
109
            raise errors.BzrCommandError(u'argument foo\xb5 does not exist')
333
320
        _rollover_trace_maybe(temp_log_name)
334
321
        # should have been rolled over
335
322
        self.assertFalse(os.access(temp_log_name, os.R_OK))
336
 
 
337
 
 
338
 
class TestTraceConfiguration(TestCaseInTempDir):
339
 
 
340
 
    def test_default_config(self):
341
 
        config = trace.DefaultConfig()
342
 
        self.overrideAttr(trace, "_bzr_log_filename", None)
343
 
        trace._bzr_log_filename = None
344
 
        expected_filename = trace._get_bzr_log_filename()
345
 
        self.assertEqual(None, trace._bzr_log_filename)
346
 
        config.__enter__()
347
 
        try:
348
 
            # Should have entered and setup a default filename.
349
 
            self.assertEqual(expected_filename, trace._bzr_log_filename)
350
 
        finally:
351
 
            config.__exit__(None, None, None)
352
 
            # Should have exited and cleaned up.
353
 
            self.assertEqual(None, trace._bzr_log_filename)