~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: 2009-08-27 02:27:19 UTC
  • mfrom: (4634.3.19 gc-batching)
  • Revision ID: pqm@pqm.ubuntu.com-20090827022719-bl2yoqhpj3fcfczu
(andrew) Fix #402657: 2a fetch over dumb transport reads one group at
        a time.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
# Copyright (C) 2005, 2006, 2007, 2008 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
12
12
#
13
13
# You should have received a copy of the GNU General Public License
14
14
# along with this program; if not, write to the Free Software
15
 
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
 
15
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
16
16
 
17
17
# "weren't nothing promised to you.  do i look like i got a promise face?"
18
18
 
48
48
class TestTrace(TestCase):
49
49
 
50
50
    def test_format_sys_exception(self):
 
51
        # Test handling of an internal/unexpected error that probably
 
52
        # indicates a bug in bzr.  The details of the message may vary
 
53
        # depending on whether apport is available or not.  See test_crash for
 
54
        # more.
51
55
        try:
52
56
            raise NotImplementedError, "time travel"
53
57
        except NotImplementedError:
56
60
        self.assertEqualDiff(err.splitlines()[0],
57
61
                'bzr: ERROR: exceptions.NotImplementedError: time travel')
58
62
        self.assertContainsRe(err,
59
 
                r'File.*test_trace.py')
 
63
            'Bazaar has encountered an internal error.')
60
64
 
61
65
    def test_format_interrupt_exception(self):
62
66
        try:
70
74
 
71
75
    def test_format_os_error(self):
72
76
        try:
 
77
            os.rmdir('nosuchfile22222')
 
78
        except OSError:
 
79
            pass
 
80
        msg = _format_exception()
 
81
        self.assertContainsRe(msg,
 
82
            r'^bzr: ERROR: \[Errno .*\] No such file.*nosuchfile22222')
 
83
 
 
84
    def test_format_io_error(self):
 
85
        try:
73
86
            file('nosuchfile22222')
74
 
        except (OSError, IOError):
 
87
        except IOError:
75
88
            pass
76
89
        msg = _format_exception()
77
90
        self.assertContainsRe(msg, r'^bzr: ERROR: \[Errno .*\] No such file.*nosuchfile')
113
126
            pass
114
127
        msg = _format_exception()
115
128
        self.assertContainsRe(msg,
116
 
            r"Traceback \(most recent call last\)")
 
129
            r'Bazaar has encountered an internal error')
117
130
 
118
131
    def test_trace_unicode(self):
119
132
        """Write Unicode to trace log"""
120
133
        self.log(u'the unicode character for benzene is \N{BENZENE RING}')
121
134
        self.assertContainsRe(self._get_log(keep_log_file=True),
122
135
                              "the unicode character for benzene is")
123
 
    
 
136
 
124
137
    def test_trace_argument_unicode(self):
125
138
        """Write a Unicode argument to the trace log"""
126
139
        mutter(u'the unicode character for benzene is %s', u'\N{BENZENE RING}')
186
199
    def test_push_log_file(self):
187
200
        """Can push and pop log file, and this catches mutter messages.
188
201
 
189
 
        This is primarily for use in the test framework. 
 
202
        This is primarily for use in the test framework.
190
203
        """
191
204
        tmp1 = tempfile.NamedTemporaryFile()
192
205
        tmp2 = tempfile.NamedTemporaryFile()