/brz/remove-bazaar

To get this branch, use:
bzr branch http://gegoxaren.bato24.eu/bzr/brz/remove-bazaar

« back to all changes in this revision

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

  • Committer: Breezy landing bot
  • Author(s): Colin Watson
  • Date: 2020-11-16 21:47:08 UTC
  • mfrom: (7521.1.1 remove-lp-workaround)
  • Revision ID: breezy.the.bot@gmail.com-20201116214708-jos209mgxi41oy15
Remove breezy.git workaround for bazaar.launchpad.net.

Merged from https://code.launchpad.net/~cjwatson/brz/remove-lp-workaround/+merge/393710

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
# Copyright (C) 2006, 2007, 2009, 2010, 2011 Canonical Ltd
 
1
# Copyright (C) 2006, 2007, 2009-2012, 2016 Canonical Ltd
2
2
#
3
3
# This program is free software; you can redistribute it and/or modify
4
4
# it under the terms of the GNU General Public License as published by
19
19
import os
20
20
import re
21
21
 
22
 
from bzrlib import (
23
 
    bzrdir,
 
22
from breezy import (
 
23
    bzr,
24
24
    config,
25
25
    controldir,
26
26
    errors,
28
28
    repository,
29
29
    tests,
30
30
    )
31
 
from bzrlib.repofmt.groupcompress_repo import RepositoryFormat2a
 
31
from breezy.bzr.groupcompress_repo import RepositoryFormat2a
32
32
 
33
33
 
34
34
class TestExceptionReporting(tests.TestCaseInTempDir):
37
37
        # we must use a subprocess, because the normal in-memory mechanism
38
38
        # allows errors to propagate up through the test suite
39
39
        out, err = self.run_bzr_subprocess(['assert-fail'],
40
 
            universal_newlines=True,
41
 
            retcode=errors.EXIT_INTERNAL_ERROR)
 
40
                                           universal_newlines=True,
 
41
                                           retcode=errors.EXIT_INTERNAL_ERROR)
42
42
        self.assertEqual(4, errors.EXIT_INTERNAL_ERROR)
43
 
        self.assertContainsRe(err,
44
 
                r'exceptions\.AssertionError: always fails\n')
45
 
        self.assertContainsRe(err, r'Bazaar has encountered an internal error')
46
 
 
47
 
    def test_undecodable_argv(self):
48
 
        """A user error must be reported if argv is not in the locale encoding
49
 
 
50
 
        A subprocess with an environment ascii-only setting is used so the test
51
 
        can run without worrying about the locale the test suite is using.
52
 
        """
53
 
        if os.name != "posix":
54
 
            raise tests.TestNotApplicable("Needs system beholden to C locales")
55
 
        out, err = self.run_bzr_subprocess(["\xa0"],
56
 
            env_changes={"LANG": "C", "LC_ALL": "C"},
57
 
            universal_newlines=True,
58
 
            retcode=errors.EXIT_ERROR)
59
 
        self.assertContainsRe(err, r"^bzr: ERROR: .*'\\xa0'.* unsupported",
60
 
            flags=re.MULTILINE)
61
 
        self.assertEquals(out, "")
 
43
        self.assertContainsRe(err, br'\nAssertionError: always fails\n')
 
44
        self.assertContainsRe(
 
45
            err, br'Bazaar has encountered an internal error')
62
46
 
63
47
    def test_utf8_default_fs_enc(self):
64
 
        """In the C locale bzr treats a posix filesystem as UTF-8 encoded"""
 
48
        """In the C locale brz treats a posix filesystem as UTF-8 encoded"""
65
49
        if os.name != "posix":
66
50
            raise tests.TestNotApplicable("Needs system beholden to C locales")
67
51
        out, err = self.run_bzr_subprocess(["init", "file:%C2%A7"],
68
 
            env_changes={"LANG": "C", "LC_ALL": "C"})
69
 
        self.assertContainsRe(out, "^Created a standalone tree .*$")
 
52
                                           env_changes={"LANG": "C", "LC_ALL": "C"})
 
53
        self.assertContainsRe(out, b"^Created a standalone tree .*$")
70
54
 
71
55
 
72
56
class TestOptParseBugHandling(tests.TestCase):
73
57
    "Test that we handle http://bugs.python.org/issue2931"
74
58
 
75
59
    def test_nonascii_optparse(self):
76
 
        """Reasonable error raised when non-ascii in option name"""
77
 
        error_re = 'Only ASCII permitted in option names'
78
 
        out = self.run_bzr_error([error_re], ['st',u'-\xe4'])
 
60
        """Reasonable error raised when non-ascii in option name on Python 2"""
 
61
        error_re = u'no such option: -\xe4'
 
62
        out = self.run_bzr_error([error_re], ['st', u'-\xe4'])
79
63
 
80
64
 
81
65
class TestObsoleteRepoFormat(RepositoryFormat2a):
82
66
 
83
67
    @classmethod
84
68
    def get_format_string(cls):
85
 
        return "Test Obsolete Repository Format"
 
69
        return b"Test Obsolete Repository Format"
86
70
 
87
71
    def is_deprecated(self):
88
72
        return True
91
75
class TestDeprecationWarning(tests.TestCaseWithTransport):
92
76
    """The deprecation warning is controlled via a global variable:
93
77
    repository._deprecation_warning_done. As such, it can be emitted only once
94
 
    during a bzr invocation, no matter how many repositories are involved.
 
78
    during a brz invocation, no matter how many repositories are involved.
95
79
 
96
80
    It would be better if it was a repo attribute instead but that's far more
97
81
    work than I want to do right now -- vila 20091215.
100
84
    def setUp(self):
101
85
        super(TestDeprecationWarning, self).setUp()
102
86
        self.addCleanup(repository.format_registry.remove,
103
 
            TestObsoleteRepoFormat)
 
87
                        TestObsoleteRepoFormat)
104
88
        repository.format_registry.register(TestObsoleteRepoFormat)
105
89
        self.addCleanup(controldir.format_registry.remove, "testobsolete")
106
 
        bzrdir.register_metadir(controldir.format_registry, "testobsolete",
107
 
            "bzrlib.tests.blackbox.test_exceptions.TestObsoleteRepoFormat",
108
 
            branch_format='bzrlib.branch.BzrBranchFormat7',
109
 
            tree_format='bzrlib.workingtree_4.WorkingTreeFormat6',
110
 
            deprecated=True,
111
 
            help='Same as 2a, but with an obsolete repo format.')
 
90
        bzr.register_metadir(controldir.format_registry, "testobsolete",
 
91
                             "breezy.tests.blackbox.test_exceptions.TestObsoleteRepoFormat",
 
92
                             branch_format='breezy.bzr.branch.BzrBranchFormat7',
 
93
                             tree_format='breezy.bzr.workingtree_4.WorkingTreeFormat6',
 
94
                             deprecated=True,
 
95
                             help='Same as 2a, but with an obsolete repo format.')
112
96
        self.disable_deprecation_warning()
113
97
 
114
98
    def enable_deprecation_warning(self, repo=None):
121
105
 
122
106
    def make_obsolete_repo(self, path):
123
107
        # We don't want the deprecation raising during the repo creation
124
 
        format = controldir.format_registry.make_bzrdir("testobsolete")
 
108
        format = controldir.format_registry.make_controldir("testobsolete")
125
109
        tree = self.make_branch_and_tree(path, format=format)
126
110
        return tree
127
111
 
130
114
            check = self.assertContainsRe
131
115
        else:
132
116
            check = self.assertNotContainsRe
133
 
        check(self.get_log(), 'WARNING.*bzr upgrade')
 
117
        check(self.get_log(), 'WARNING.*brz upgrade')
134
118
 
135
119
    def test_repository_deprecation_warning(self):
136
120
        """Old formats give a warning"""