~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/tests/test_trace.py

  • Committer: Martin Pool
  • Date: 2011-03-28 01:28:09 UTC
  • mto: (5425.4.19 220464-stale-locks)
  • mto: This revision was merged to the branch mainline in revision 5970.
  • Revision ID: mbp@canonical.com-20110328012809-frw003r09tcrxkiz
Represent lock held info as an object, not just a dict

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
# Copyright (C) 2005-2011 Canonical Ltd
 
1
# Copyright (C) 2005-2010 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
26
26
import tempfile
27
27
 
28
28
from bzrlib import (
29
 
    debug,
30
29
    errors,
31
30
    trace,
32
31
    )
82
81
            pass
83
82
        msg = _format_exception()
84
83
        self.assertEquals(msg,
85
 
            "bzr: out of memory\nUse -Dmem_dump to dump memory to a file.\n")
86
 
 
87
 
    def test_format_mem_dump(self):
88
 
        self.requireFeature(features.meliae)
89
 
        debug.debug_flags.add('mem_dump')
90
 
        try:
91
 
            raise MemoryError()
92
 
        except MemoryError:
93
 
            pass
94
 
        msg = _format_exception()
95
 
        self.assertStartsWith(msg,
96
 
            "bzr: out of memory\nMemory dumped to ")
 
84
            "bzr: out of memory\n")
97
85
 
98
86
    def test_format_os_error(self):
99
87
        try:
301
289
        # set up.
302
290
        self.overrideAttr(sys, 'stderr', StringIO())
303
291
        # Set the log file to something that cannot exist
304
 
        self.overrideEnv('BZR_LOG', os.getcwd() + '/no-dir/bzr.log')
 
292
        # FIXME: A bit dangerous: we are not in an isolated dir here -- vilajam
 
293
        # 20100125
 
294
        os.environ['BZR_LOG'] = os.getcwd() + '/no-dir/bzr.log'
305
295
        self.overrideAttr(trace, '_bzr_log_filename')
306
296
        logf = trace._open_bzr_log()
307
297
        self.assertIs(None, logf)