~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

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

  • Committer: Andrew Bennetts
  • Date: 2011-02-14 11:57:45 UTC
  • mto: This revision was merged to the branch mainline in revision 5664.
  • Revision ID: andrew.bennetts@canonical.com-20110214115745-gzb0nn2whvs4unp7
Preserve identity of default values in the pretty decorators.

Show diffs side-by-side

added added

removed removed

Lines of Context:
16
16
 
17
17
"""Tests for display of exceptions."""
18
18
 
19
 
import os
20
19
import sys
21
20
 
22
21
from bzrlib import (
23
22
    bzrdir,
24
23
    config,
25
 
    controldir,
26
24
    errors,
27
25
    osutils,
28
26
    repository,
29
27
    tests,
30
28
    )
31
 
from bzrlib.repofmt.groupcompress_repo import RepositoryFormat2a
32
29
 
33
30
from bzrlib.tests import TestCase
34
31
 
46
43
                r'exceptions\.AssertionError: always fails\n')
47
44
        self.assertContainsRe(err, r'Bazaar has encountered an internal error')
48
45
 
49
 
    def test_undecodable_argv(self):
50
 
        """A user error must be reported if argv is not in the locale encoding
51
 
 
52
 
        A subprocess with an environment ascii-only setting is used so the test
53
 
        can run without worrying about the locale the test suite is using.
54
 
        """
55
 
        if os.name != "posix":
56
 
            raise tests.TestNotApplicable("Needs system beholden to C locales")
57
 
        out, err = self.run_bzr_subprocess(["\xa0"],
58
 
            env_changes={"LANG": "C", "LC_ALL": "C"},
59
 
            universal_newlines=True,
60
 
            retcode=errors.EXIT_ERROR)
61
 
        self.assertContainsRe(err, r"^bzr: ERROR: .*'\\xa0'.* unsupported")
62
 
        self.assertEquals(out, "")
63
 
 
64
46
 
65
47
class TestOptParseBugHandling(TestCase):
66
48
    "Test that we handle http://bugs.python.org/issue2931"
74
56
        out = self.run_bzr_error([error_re], ['st',u'-\xe4'])
75
57
 
76
58
 
77
 
class TestObsoleteRepoFormat(RepositoryFormat2a):
78
 
 
79
 
    @classmethod
80
 
    def get_format_string(cls):
81
 
        return "Test Obsolete Repository Format"
82
 
 
83
 
    def is_deprecated(self):
84
 
        return True
85
 
 
86
 
 
87
59
class TestDeprecationWarning(tests.TestCaseWithTransport):
88
60
    """The deprecation warning is controlled via a global variable:
89
61
    repository._deprecation_warning_done. As such, it can be emitted only once
95
67
 
96
68
    def setUp(self):
97
69
        super(TestDeprecationWarning, self).setUp()
98
 
        self.addCleanup(repository.format_registry.remove,
99
 
            TestObsoleteRepoFormat)
100
 
        repository.format_registry.register(TestObsoleteRepoFormat)
101
 
        self.addCleanup(controldir.format_registry.remove, "testobsolete")
102
 
        bzrdir.register_metadir(controldir.format_registry, "testobsolete",
103
 
            "bzrlib.tests.blackbox.test_exceptions.TestObsoleteRepoFormat",
104
 
            branch_format='bzrlib.branch.BzrBranchFormat7',
105
 
            tree_format='bzrlib.workingtree_4.WorkingTreeFormat6',
106
 
            deprecated=True,
107
 
            help='Same as 2a, but with an obsolete repo format.')
108
70
        self.disable_deprecation_warning()
109
71
 
110
72
    def enable_deprecation_warning(self, repo=None):
117
79
 
118
80
    def make_obsolete_repo(self, path):
119
81
        # We don't want the deprecation raising during the repo creation
120
 
        format = controldir.format_registry.make_bzrdir("testobsolete")
121
 
        tree = self.make_branch_and_tree(path, format=format)
 
82
        tree = self.make_branch_and_tree(path, format=bzrdir.BzrDirFormat5())
122
83
        return tree
123
84
 
124
85
    def check_warning(self, present):