~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/tests/blackbox/test_exceptions.py

  • Committer: Martin Pool
  • Date: 2009-09-14 01:48:28 UTC
  • mfrom: (4685 +trunk)
  • mto: This revision was merged to the branch mainline in revision 4688.
  • Revision ID: mbp@sourcefrog.net-20090914014828-ydr9rlkdfq2sv57z
Merge news

Show diffs side-by-side

added added

removed removed

Lines of Context:
33
33
 
34
34
class TestExceptionReporting(TestCase):
35
35
 
36
 
    def test_report_exception(self):
37
 
        """When an error occurs, display bug report details to stderr"""
38
 
        try:
39
 
            raise AssertionError("failed")
40
 
        except AssertionError, e:
41
 
            erf = StringIO()
42
 
            trace.report_exception(sys.exc_info(), erf)
43
 
        err = erf.getvalue()
44
 
        self.assertContainsRe(err,
45
 
            r'bzr: ERROR: exceptions\.AssertionError: failed\n')
46
 
        self.assertContainsRe(err,
47
 
            r'Please report a bug at https://bugs\.launchpad\.net/bzr/\+filebug')
48
 
        self.assertContainsRe(err,
49
 
            '(?m)^encoding: .*, fsenc: .*, lang: .*')
50
 
        self.assertContainsRe(err,
51
 
            '(?m)^plugins:$')
52
 
 
53
36
    def test_exception_exitcode(self):
54
37
        # we must use a subprocess, because the normal in-memory mechanism
55
38
        # allows errors to propagate up through the test suite
58
41
            retcode=errors.EXIT_INTERNAL_ERROR)
59
42
        self.assertEqual(4, errors.EXIT_INTERNAL_ERROR)
60
43
        self.assertContainsRe(err,
61
 
                r'bzr: ERROR: exceptions\.AssertionError: always fails\n')
62
 
        self.assertContainsRe(err, r'Please report a bug at')
 
44
                r'exceptions\.AssertionError: always fails\n')
 
45
        self.assertContainsRe(err, r'Bazaar has encountered an internal error')
63
46
 
64
47
 
65
48
class TestDeprecationWarning(TestCaseInTempDir):