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())
46
46
stderr = StringIO()
72
72
self.assertContainsRe(report, 'test_apport_report')
73
73
# should also be in there
74
74
self.assertContainsRe(report, '(?m)^CommandLine:')
77
class TestNonApportReporting(tests.TestCase):
78
"""Reporting of crash-type bugs without apport.
80
This should work in all environments.
83
def setup_fake_plugins(self):
85
fake = plugin.PlugIn('fake_plugin', plugin)
86
fake.version_info = lambda: (1, 2, 3)
87
return {"fake_plugin": fake}
88
self.overrideAttr(plugin, 'plugins', fake_plugins)
90
def test_report_bug_legacy(self):
91
self.setup_fake_plugins()
94
raise AssertionError("my error")
95
except AssertionError, e:
97
crash.report_bug_legacy(sys.exc_info(), err_file)
101
bzr: ERROR: exceptions.AssertionError: my error
103
Traceback (most recent call last):
105
AssertionError: my error
107
bzr ... on python ...
109
plugins: fake_plugin[1.2.3]
112
*** Bazaar has encountered an internal error. This probably indicates a
113
bug in Bazaar. You can help us fix it by filing a bug report at
114
https://bugs.launchpad.net/bzr/+filebug
115
including this traceback and a description of the problem.
116
""", flags=doctest.ELLIPSIS|doctest.REPORT_UDIFF))