~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

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

  • Committer: Canonical.com Patch Queue Manager
  • Date: 2006-11-08 18:43:09 UTC
  • mfrom: (2123.1.2 integration)
  • Revision ID: pqm@pqm.ubuntu.com-20061108184309-7f42d0212467bea2
(Robert Collins) When apport is present on a system, use it to gather more information for bug reporting, and present a less intimidating request that the user submit a bug report

Show diffs side-by-side

added added

removed removed

Lines of Context:
19
19
import os
20
20
import sys
21
21
 
22
 
from bzrlib import bzrdir, repository
23
 
 
24
 
from bzrlib.tests import TestCaseInTempDir, TestCase
 
22
from bzrlib import bzrdir, repository, trace
 
23
from bzrlib.tests import TestCaseInTempDir, TestCase, TestSkipped
25
24
from bzrlib.errors import NotBranchError
26
25
 
 
26
 
27
27
class TestExceptionReporting(TestCase):
28
28
 
29
29
    def test_report_exception(self):
30
30
        """When an error occurs, display bug report details to stderr"""
31
 
        out, err = self.run_bzr("assert-fail", retcode=3)
32
 
        self.assertContainsRe(err,
33
 
                r'bzr: ERROR: exceptions\.AssertionError: always fails\n')
34
 
        self.assertContainsRe(err, r'please send this report to')
 
31
        old_use_apport = trace._use_apport
 
32
        trace._use_apport = False
 
33
        try:
 
34
            self.run_bzr_error(
 
35
                [
 
36
                    r'bzr: ERROR: exceptions\.AssertionError: always fails\n',
 
37
                    r'please send this report to',
 
38
                ],
 
39
                "assert-fail")
 
40
        finally:
 
41
            trace._use_apport = old_use_apport
 
42
 
 
43
    def test_apport_report(self):
 
44
        # If apport is present, bzr should tell the user the url to visit to 
 
45
        # file the bug, and the file to upload as an attachment containing the
 
46
        # backtrace, installed versions, plugin information etc.
 
47
        # the file contents are tested in the library tests, this test just
 
48
        # checks the ui.
 
49
        try:
 
50
            import apport_utils
 
51
        except ImportError:
 
52
            raise TestSkipped('apport not present')
 
53
        out, err = self.run_bzr_error(
 
54
            [
 
55
                r'bzr: ERROR: exceptions\.AssertionError: always fails\n',
 
56
                r'This is an unexpected error within bzr and we would appreciate a bug report.\n',
 
57
                r'bzr has written a crash report file that will assist our debugging of this\n',
 
58
                r'in the file /tmp/bzr-crash-[a-zA-Z0-9_]+\.txt\n',
 
59
                r'This is a plain text file, whose contents you can check if you have privacy\n',
 
60
                r'concerns. We gather the package data about bzr, your command line, plugins\n',
 
61
                r'And the backtrace from within bzr. If you had a password in the URL you\n',
 
62
                r'provided to bzr, you should edit that file to remove the password.\n',
 
63
                r'\*\* To file a bug for this please visit our bugtracker at the URL \n',
 
64
                r'"https://launchpad.net/products/bzr/\+filebug" and report a bug describing\n',
 
65
                r'what you were attempting and attach the bzr-crash file mentioned above.\n',
 
66
                r'Alternatively you can email bazaar-ng@lists.canonical.com with the same\n',
 
67
                r'description and attach the bzr-crash file to the email\.\n',
 
68
            ],
 
69
            "assert-fail")
 
70
        self.assertEqualDiff('', out)
 
71
 
35
72
 
36
73
    # TODO: assert-fail doesn't need to always be present; we could just
37
74
    # register (and unregister) it from tests that want to touch it.