~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/tests/test_trace.py

  • Committer: Andrew Bennetts
  • Date: 2010-10-13 00:26:41 UTC
  • mto: This revision was merged to the branch mainline in revision 5498.
  • Revision ID: andrew.bennetts@canonical.com-20101013002641-9tlh9k89mlj1666m
Keep docs-plain working.

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:
128
116
        #                with errno, function name, and locale error message
129
117
        self.assertContainsRe(msg,
130
118
            r"^bzr: ERROR: \(2, 'RemoveDirectory[AW]?', .*\)")
131
 
            
132
 
    def test_format_sockets_error(self):
133
 
        try:
134
 
            import socket
135
 
            sock = socket.socket()
136
 
            sock.send("This should fail.")
137
 
        except socket.error:
138
 
            pass
139
 
        msg = _format_exception()
140
 
        
141
 
        self.assertNotContainsRe(msg,
142
 
            r"Traceback (most recent call last):")
143
119
 
144
120
    def test_format_unicode_error(self):
145
121
        try:
313
289
        # set up.
314
290
        self.overrideAttr(sys, 'stderr', StringIO())
315
291
        # Set the log file to something that cannot exist
316
 
        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'
317
295
        self.overrideAttr(trace, '_bzr_log_filename')
318
296
        logf = trace._open_bzr_log()
319
297
        self.assertIs(None, logf)