1
# Copyright (C) 2009 Canonical Ltd
1
# Copyright (C) 2009, 2010 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
18
18
from StringIO import StringIO
21
25
from bzrlib import (
26
33
from bzrlib.tests import features
29
class TestApportReporting(tests.TestCase):
36
class TestApportReporting(tests.TestCaseInTempDir):
31
38
_test_needs_features = [features.apport]
33
def test_apport_report_contents(self):
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())
35
49
raise AssertionError("my error")
36
50
except AssertionError, e:
39
crash._write_apport_report_to_file(sys.exc_info(), outf)
40
report = outf.getvalue()
42
self.assertContainsRe(report, '(?m)^BzrVersion:')
43
# should be in the traceback
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
44
68
self.assertContainsRe(report, 'my error')
45
69
self.assertContainsRe(report, 'AssertionError')
46
self.assertContainsRe(report, 'test_apport_report_contents')
70
self.assertContainsRe(report, 'test_apport_report')
47
71
# should also be in there
48
72
self.assertContainsRe(report, '(?m)^CommandLine:')