~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-09-14 09:47:23 UTC
  • mto: (5452.4.1 jam-integration)
  • mto: This revision was merged to the branch mainline in revision 5476.
  • Revision ID: mbp@sourcefrog.net-20100914094723-2dn6e9q5ktpa1m8r
Update existing script tests to not ignore their output

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)