~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/tests/test_trace.py

  • Committer: John Arbash Meinel
  • Date: 2011-05-11 11:35:28 UTC
  • mto: This revision was merged to the branch mainline in revision 5851.
  • Revision ID: john@arbash-meinel.com-20110511113528-qepibuwxicjrbb2h
Break compatibility with python <2.6.

This includes auditing the code for places where we were doing
explicit 'sys.version' checks and removing them as appropriate.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
# Copyright (C) 2005-2010 Canonical Ltd
 
1
# Copyright (C) 2005-2011 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,
29
30
    errors,
30
31
    trace,
31
32
    )
81
82
            pass
82
83
        msg = _format_exception()
83
84
        self.assertEquals(msg,
84
 
            "bzr: out of memory\n")
 
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 ")
85
97
 
86
98
    def test_format_os_error(self):
87
99
        try:
289
301
        # set up.
290
302
        self.overrideAttr(sys, 'stderr', StringIO())
291
303
        # Set the log file to something that cannot exist
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'
 
304
        self.overrideEnv('BZR_LOG', os.getcwd() + '/no-dir/bzr.log')
295
305
        self.overrideAttr(trace, '_bzr_log_filename')
296
306
        logf = trace._open_bzr_log()
297
307
        self.assertIs(None, logf)