/brz/remove-bazaar

To get this branch, use:
bzr branch http://gegoxaren.bato24.eu/bzr/brz/remove-bazaar
2052.3.2 by John Arbash Meinel
Change Copyright .. by Canonical to Copyright ... Canonical
1
# Copyright (C) 2006 Canonical Ltd
1740.5.1 by Martin Pool
When an unhandled exception occurs, write the traceback to stderr.
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., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
16
17
"""Tests for display of exceptions."""
18
19
import os
20
import sys
21
2123.1.1 by Robert Collins
(Robert Collins) Extend the problem reporting command line UI to use
22
from bzrlib import bzrdir, repository, trace
2123.1.2 by Robert Collins
Ensure TestSkipped is present for skipping when new test dependency on apport is missing.
23
from bzrlib.tests import TestCaseInTempDir, TestCase, TestSkipped
1740.5.6 by Martin Pool
Clean up many exception classes.
24
from bzrlib.errors import NotBranchError
1740.5.1 by Martin Pool
When an unhandled exception occurs, write the traceback to stderr.
25
2123.1.1 by Robert Collins
(Robert Collins) Extend the problem reporting command line UI to use
26
1740.5.1 by Martin Pool
When an unhandled exception occurs, write the traceback to stderr.
27
class TestExceptionReporting(TestCase):
28
1740.5.2 by Martin Pool
Improved tests for display of exceptions.
29
    def test_report_exception(self):
1740.5.1 by Martin Pool
When an unhandled exception occurs, write the traceback to stderr.
30
        """When an error occurs, display bug report details to stderr"""
2123.1.1 by Robert Collins
(Robert Collins) Extend the problem reporting command line UI to use
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
1740.5.1 by Martin Pool
When an unhandled exception occurs, write the traceback to stderr.
72
73
    # TODO: assert-fail doesn't need to always be present; we could just
74
    # register (and unregister) it from tests that want to touch it.
75
    #
1740.5.7 by Martin Pool
Add test for formatting of EPIPE
76
    # TODO: Some kind of test for the feature of invoking pdb
1904.2.5 by Martin Pool
Fix format warning inside test suite and add test
77
    
78
79
class TestDeprecationWarning(TestCaseInTempDir):
80
81
    def test_repository_deprecation_warning(self):
82
        """Old formats give a warning"""
83
        # the warning's normally off for testing but we reenable it
84
        repository._deprecation_warning_done = False
85
        try:
86
            os.mkdir('foo')
87
            bzrdir.BzrDirFormat5().initialize('foo')
88
            out, err = self.run_bzr("status", "foo")
1927.3.1 by Carl Friedrich Bolz
Throw away on-disk logfile when possible.
89
            self.assertContainsRe(self._get_log(keep_log_file=True),
90
                                  "bzr upgrade")
1904.2.5 by Martin Pool
Fix format warning inside test suite and add test
91
        finally:
92
            repository._deprecation_warning_done = True
93