1
# Copyright (C) 2009, 2010 Canonical Ltd
3
# This program is free software; you can redistribute it and/or modify
4
# it under the terms of the GNU General Public License as published by
5
# the Free Software Foundation; either version 2 of the License, or
6
# (at your option) any later version.
8
# This program is distributed in the hope that it will be useful,
9
# but WITHOUT ANY WARRANTY; without even the implied warranty of
10
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11
# GNU General Public License for more details.
13
# You should have received a copy of the GNU General Public License
14
# along with this program; if not, write to the Free Software
15
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
18
from StringIO import StringIO
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())
49
raise AssertionError("my error")
50
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
self.assertContainsRe(report, 'test_apport_report')
71
# should also be in there
72
self.assertContainsRe(report, '(?m)^CommandLine:')