1
# Copyright (C) 2009 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
22
from bzrlib.crash import (
24
_write_apport_report_to_file,
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):
38
raise AssertionError("my error")
39
except AssertionError, e:
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')
55
# should also be in there
56
self.assertContainsRe(report,
57
'(?m)^CommandLine:.*selftest')