~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/tests/test_trace.py

  • Committer: Canonical.com Patch Queue Manager
  • Date: 2010-01-07 17:02:44 UTC
  • mfrom: (4934.1.14 2.1.0rc1-set-mtime)
  • Revision ID: pqm@pqm.ubuntu.com-20100107170244-3cgdapvuokgf8l42
(jam,
        gz) (bug #488724) Set the mtime of files touched in a TreeTransform.

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
27
27
 
28
28
from bzrlib import (
29
29
    errors,
30
 
    trace,
31
30
    )
32
31
from bzrlib.tests import TestCaseInTempDir, TestCase
33
32
from bzrlib.trace import (
36
35
    pop_log_file,
37
36
    push_log_file,
38
37
    _rollover_trace_maybe,
39
 
    show_error,
40
38
    )
41
39
 
42
40
 
216
214
        # have to do a replaceent here as well.
217
215
        self.assertContainsRe(log, "ascii argument: \xb5".decode('utf8',
218
216
            'replace'))
219
 
        
220
 
    def test_show_error(self):
221
 
        show_error('error1')
222
 
        show_error(u'error2 \xb5 blah')
223
 
        show_error('arg: %s', 'blah')
224
 
        show_error('arg2: %(key)s', {'key':'stuff'})
225
 
        try:
226
 
            raise Exception("oops")
227
 
        except:
228
 
            show_error('kwarg', exc_info=True)
229
 
        log = self.get_log()
230
 
        self.assertContainsRe(log, 'error1')
231
 
        self.assertContainsRe(log, u'error2 \xb5 blah')
232
 
        self.assertContainsRe(log, 'arg: blah')
233
 
        self.assertContainsRe(log, 'arg2: stuff')
234
 
        self.assertContainsRe(log, 'kwarg')
235
 
        self.assertContainsRe(log, 'Traceback \\(most recent call last\\):')
236
 
        self.assertContainsRe(log, 'File ".*test_trace.py", line .*, in test_show_error')
237
 
        self.assertContainsRe(log, 'raise Exception\\("oops"\\)')
238
 
        self.assertContainsRe(log, 'Exception: oops')
239
217
 
240
218
    def test_push_log_file(self):
241
219
        """Can push and pop log file, and this catches mutter messages.
270
248
            tmp1.close()
271
249
            tmp2.close()
272
250
 
273
 
    def test__open_bzr_log_uses_stderr_for_failures(self):
274
 
        # If _open_bzr_log cannot open the file, then we should write the
275
 
        # warning to stderr. Since this is normally happening before logging is
276
 
        # set up.
277
 
        self.overrideAttr(sys, 'stderr', StringIO())
278
 
        # Set the log file to something that cannot exist
279
 
        # FIXME: A bit dangerous: we are not in an isolated dir here -- vilajam
280
 
        # 20100125
281
 
        os.environ['BZR_LOG'] = os.getcwd() + '/no-dir/bzr.log'
282
 
        self.overrideAttr(trace, '_bzr_log_filename')
283
 
        logf = trace._open_bzr_log()
284
 
        self.assertIs(None, logf)
285
 
        self.assertContainsRe(sys.stderr.getvalue(),
286
 
                              'failed to open trace file: .*/no-dir/bzr.log')
287
 
 
288
251
 
289
252
class TestVerbosityLevel(TestCase):
290
253