22
from bzrlib.crash import (
24
_write_apport_report_to_file,
33
from bzrlib.tests import features
36
class TestApportReporting(tests.TestCaseInTempDir):
38
_test_needs_features = [features.apport]
40
def test_apport_report(self):
41
crash_dir = osutils.joinpath((self.test_base_dir, 'crash'))
43
os.environ['APPORT_CRASH_DIR'] = crash_dir
44
self.assertEquals(crash_dir, config.crash_dir())
26
from bzrlib.tests import TestCase
27
from bzrlib.tests.features import ApportFeature
30
class TestApportReporting(TestCase):
34
self.requireFeature(ApportFeature)
36
def test_apport_report_contents(self):
49
38
raise AssertionError("my error")
50
39
except AssertionError, e:
53
crash_filename = crash.report_bug_to_apport(sys.exc_info(),
56
# message explaining the crash
57
self.assertContainsRe(stderr.getvalue(),
58
" apport-bug %s" % crash_filename)
60
crash_file = open(crash_filename)
62
report = crash_file.read()
66
self.assertContainsRe(report,
67
'(?m)^BzrVersion:') # should be in the traceback
68
self.assertContainsRe(report, 'my error')
69
self.assertContainsRe(report, 'AssertionError')
70
# see https://bugs.launchpad.net/bzr/+bug/528114
71
self.assertContainsRe(report, 'ExecutablePath')
72
self.assertContainsRe(report, 'test_apport_report')
42
_write_apport_report_to_file(sys.exc_info(),
44
report = outf.getvalue()
46
self.assertContainsRe(report,
48
# should be in the traceback
49
self.assertContainsRe(report,
51
self.assertContainsRe(report,
53
self.assertContainsRe(report,
54
'test_apport_report_contents')
73
55
# should also be in there
74
self.assertContainsRe(report, '(?m)^CommandLine:')
56
self.assertContainsRe(report,
57
'(?m)^CommandLine:.*selftest')