1
# Copyright (C) 2009, 2010 Canonical Ltd
1
# Copyright (C) 2009, 2010, 2011 Canonical Ltd
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
15
15
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
18
20
from StringIO import StringIO
23
from testtools.matchers import DocTestMatches
25
25
from bzrlib import (
40
40
def test_apport_report(self):
41
41
crash_dir = osutils.joinpath((self.test_base_dir, 'crash'))
42
42
os.mkdir(crash_dir)
43
os.environ['APPORT_CRASH_DIR'] = crash_dir
43
self.overrideEnv('APPORT_CRASH_DIR', crash_dir)
44
44
self.assertEquals(crash_dir, config.crash_dir())
49
{'example': ['Failed to load plugin foo']})
46
51
stderr = StringIO()
72
77
self.assertContainsRe(report, 'test_apport_report')
73
78
# should also be in there
74
79
self.assertContainsRe(report, '(?m)^CommandLine:')
80
self.assertContainsRe(
82
'Failed to load plugin foo')
85
class TestNonApportReporting(tests.TestCase):
86
"""Reporting of crash-type bugs without apport.
88
This should work in all environments.
91
def setup_fake_plugins(self):
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)
98
def test_report_bug_legacy(self):
99
self.setup_fake_plugins()
100
err_file = StringIO()
102
raise AssertionError("my error")
103
except AssertionError, e:
105
crash.report_bug_legacy(sys.exc_info(), err_file)
109
bzr: ERROR: exceptions.AssertionError: my error
111
Traceback (most recent call last):
113
AssertionError: my error
115
bzr ... on python ...
117
plugins: fake_plugin[1.2.3]
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))