~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/tests/test_crash.py

  • Committer: Andrew Bennetts
  • Date: 2011-02-14 12:03:05 UTC
  • mto: This revision was merged to the branch mainline in revision 5664.
  • Revision ID: andrew.bennetts@canonical.com-20110214120305-7l7iu1h6f13voeo7
Add release note.

Show diffs side-by-side

added added

removed removed

Lines of Context:
15
15
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
16
16
 
17
17
 
18
 
import doctest
19
 
import os
20
18
from StringIO import StringIO
21
19
import sys
22
20
 
23
 
from testtools.matchers import DocTestMatches
 
21
 
 
22
import os
 
23
 
24
24
 
25
25
from bzrlib import (
26
26
    config,
80
80
        self.assertContainsRe(
81
81
            report,
82
82
            'Failed to load plugin foo')
83
 
 
84
 
 
85
 
class TestNonApportReporting(tests.TestCase):
86
 
    """Reporting of crash-type bugs without apport.
87
 
    
88
 
    This should work in all environments.
89
 
    """
90
 
 
91
 
    def setup_fake_plugins(self):
92
 
        def fake_plugins():
93
 
            fake = plugin.PlugIn('fake_plugin', plugin)
94
 
            fake.version_info = lambda: (1, 2, 3)
95
 
            return {"fake_plugin": fake}
96
 
        self.overrideAttr(plugin, 'plugins', fake_plugins)
97
 
 
98
 
    def test_report_bug_legacy(self):
99
 
        self.setup_fake_plugins()
100
 
        err_file = StringIO()
101
 
        try:
102
 
            raise AssertionError("my error")
103
 
        except AssertionError, e:
104
 
            pass
105
 
        crash.report_bug_legacy(sys.exc_info(), err_file)
106
 
        self.assertThat(
107
 
            err_file.getvalue(),
108
 
            DocTestMatches("""\
109
 
bzr: ERROR: exceptions.AssertionError: my error
110
 
 
111
 
Traceback (most recent call last):
112
 
  ...
113
 
AssertionError: my error
114
 
 
115
 
bzr ... on python ...
116
 
arguments: ...
117
 
plugins: fake_plugin[1.2.3]
118
 
encoding: ...
119
 
 
120
 
*** Bazaar has encountered an internal error.  This probably indicates a
121
 
    bug in Bazaar.  You can help us fix it by filing a bug report at
122
 
        https://bugs.launchpad.net/bzr/+filebug
123
 
    including this traceback and a description of the problem.
124
 
""", flags=doctest.ELLIPSIS|doctest.REPORT_UDIFF))