22
from bzrlib import bzrdir, repository, trace
23
from bzrlib.tests import TestCaseInTempDir, TestCase, TestSkipped
22
from bzrlib import bzrdir, repository
24
from bzrlib.tests import TestCaseInTempDir, TestCase
24
25
from bzrlib.errors import NotBranchError
27
27
class TestExceptionReporting(TestCase):
29
29
def test_report_exception(self):
30
30
"""When an error occurs, display bug report details to stderr"""
31
old_use_apport = trace._use_apport
32
trace._use_apport = False
36
r'bzr: ERROR: exceptions\.AssertionError: always fails\n',
37
r'please send this report to',
41
trace._use_apport = old_use_apport
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
52
raise TestSkipped('apport not present')
53
out, err = self.run_bzr_error(
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',
70
self.assertEqualDiff('', out)
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')
73
36
# TODO: assert-fail doesn't need to always be present; we could just
74
37
# register (and unregister) it from tests that want to touch it.