4584.3.21
by Martin Pool
Start adding tests for apport |
1 |
# Copyright (C) 2009 Canonical Ltd
|
2 |
#
|
|
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.
|
|
7 |
#
|
|
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.
|
|
12 |
#
|
|
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
|
|
16 |
||
17 |
||
18 |
from StringIO import StringIO |
|
19 |
import sys |
|
20 |
||
4660.1.1
by Vincent Ladeuil
Let user decide what command is used to run the test suite. |
21 |
from bzrlib import ( |
22 |
crash, |
|
23 |
tests, |
|
4584.3.21
by Martin Pool
Start adding tests for apport |
24 |
)
|
4660.1.1
by Vincent Ladeuil
Let user decide what command is used to run the test suite. |
25 |
|
4660.1.2
by Vincent Ladeuil
Review feedback, fix typo and more cleanups. |
26 |
from bzrlib.tests import features |
4660.1.1
by Vincent Ladeuil
Let user decide what command is used to run the test suite. |
27 |
|
28 |
||
29 |
class TestApportReporting(tests.TestCase): |
|
30 |
||
4913.2.19
by John Arbash Meinel
Compatibly rename ApportFeature to features.apport. |
31 |
_test_needs_features = [features.apport] |
4584.3.21
by Martin Pool
Start adding tests for apport |
32 |
|
33 |
def test_apport_report_contents(self): |
|
34 |
try: |
|
35 |
raise AssertionError("my error") |
|
36 |
except AssertionError, e: |
|
37 |
pass
|
|
38 |
outf = StringIO() |
|
4660.1.2
by Vincent Ladeuil
Review feedback, fix typo and more cleanups. |
39 |
crash._write_apport_report_to_file(sys.exc_info(), outf) |
4584.3.21
by Martin Pool
Start adding tests for apport |
40 |
report = outf.getvalue() |
41 |
||
4660.1.2
by Vincent Ladeuil
Review feedback, fix typo and more cleanups. |
42 |
self.assertContainsRe(report, '(?m)^BzrVersion:') |
4584.3.21
by Martin Pool
Start adding tests for apport |
43 |
# should be in the traceback
|
4660.1.2
by Vincent Ladeuil
Review feedback, fix typo and more cleanups. |
44 |
self.assertContainsRe(report, 'my error') |
45 |
self.assertContainsRe(report, 'AssertionError') |
|
46 |
self.assertContainsRe(report, 'test_apport_report_contents') |
|
4584.3.22
by Martin Pool
further tweaks to and tests of bzr apport reporting |
47 |
# should also be in there
|
4660.1.2
by Vincent Ladeuil
Review feedback, fix typo and more cleanups. |
48 |
self.assertContainsRe(report, '(?m)^CommandLine:') |