~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/tests/test_crash.py

MergeĀ lp:bzr.

Show diffs side-by-side

added added

removed removed

Lines of Context:
18
18
from StringIO import StringIO
19
19
import sys
20
20
 
21
 
 
22
 
from bzrlib.crash import (
23
 
    report_bug,
24
 
    _write_apport_report_to_file,
 
21
from bzrlib import (
 
22
    crash,
 
23
    tests,
25
24
    )
26
 
from bzrlib.tests import TestCase
27
 
from bzrlib.tests.features import ApportFeature
28
 
 
29
 
 
30
 
class TestApportReporting(TestCase):
31
 
 
32
 
    def setUp(self):
33
 
        TestCase.setUp(self)
34
 
        self.requireFeature(ApportFeature)
 
25
 
 
26
from bzrlib.tests import features
 
27
 
 
28
 
 
29
class TestApportReporting(tests.TestCase):
 
30
 
 
31
    _test_needs_features = [features.ApportFeature]
35
32
 
36
33
    def test_apport_report_contents(self):
37
34
        try:
39
36
        except AssertionError, e:
40
37
            pass
41
38
        outf = StringIO()
42
 
        _write_apport_report_to_file(sys.exc_info(),
43
 
            outf)
 
39
        crash._write_apport_report_to_file(sys.exc_info(), outf)
44
40
        report = outf.getvalue()
45
41
 
46
 
        self.assertContainsRe(report,
47
 
            '(?m)^BzrVersion:')
 
42
        self.assertContainsRe(report, '(?m)^BzrVersion:')
48
43
        # should be in the traceback
49
 
        self.assertContainsRe(report,
50
 
            'my error')
51
 
        self.assertContainsRe(report,
52
 
            'AssertionError')
53
 
        self.assertContainsRe(report,
54
 
            'test_apport_report_contents')
 
44
        self.assertContainsRe(report, 'my error')
 
45
        self.assertContainsRe(report, 'AssertionError')
 
46
        self.assertContainsRe(report, 'test_apport_report_contents')
55
47
        # should also be in there
56
 
        self.assertContainsRe(report,
57
 
            '(?m)^CommandLine:.*selftest')
 
48
        self.assertContainsRe(report, '(?m)^CommandLine:')