/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: Jelmer Vernooij
  • Date: 2017-07-23 22:06:41 UTC
  • mfrom: (6738 trunk)
  • mto: This revision was merged to the branch mainline in revision 6739.
  • Revision ID: jelmer@jelmer.uk-20170723220641-69eczax9bmv8d6kk
Merge trunk, address review comments.

Show diffs side-by-side

added added

removed removed

Lines of Context:
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, br'\nAssertionError: always fails\n')
44
 
        self.assertContainsRe(
45
 
            err, br'Bazaar has encountered an internal error')
 
43
        self.assertContainsRe(err, r'\nAssertionError: always fails\n')
 
44
        self.assertContainsRe(err, r'Bazaar has encountered an internal error')
 
45
 
 
46
    def test_undecodable_argv(self):
 
47
        """A user error must be reported if argv is not in the locale encoding
 
48
 
 
49
        A subprocess with an environment ascii-only setting is used so the test
 
50
        can run without worrying about the locale the test suite is using.
 
51
        """
 
52
        if os.name != "posix":
 
53
            raise tests.TestNotApplicable("Needs system beholden to C locales")
 
54
        out, err = self.run_bzr_subprocess(["\xa0"],
 
55
            env_changes={"LANG": "C", "LC_ALL": "C"},
 
56
            universal_newlines=True,
 
57
            retcode=errors.EXIT_ERROR)
 
58
        self.assertContainsRe(err, r"^brz: ERROR: .*'\\xa0'.* unsupported",
 
59
            flags=re.MULTILINE)
 
60
        self.assertEqual(out, "")
46
61
 
47
62
    def test_utf8_default_fs_enc(self):
48
63
        """In the C locale brz treats a posix filesystem as UTF-8 encoded"""
49
64
        if os.name != "posix":
50
65
            raise tests.TestNotApplicable("Needs system beholden to C locales")
51
66
        out, err = self.run_bzr_subprocess(["init", "file:%C2%A7"],
52
 
                                           env_changes={"LANG": "C", "LC_ALL": "C"})
53
 
        self.assertContainsRe(out, b"^Created a standalone tree .*$")
 
67
            env_changes={"LANG": "C", "LC_ALL": "C"})
 
68
        self.assertContainsRe(out, "^Created a standalone tree .*$")
54
69
 
55
70
 
56
71
class TestOptParseBugHandling(tests.TestCase):
57
72
    "Test that we handle http://bugs.python.org/issue2931"
58
73
 
59
74
    def test_nonascii_optparse(self):
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'])
 
75
        """Reasonable error raised when non-ascii in option name"""
 
76
        error_re = 'Only ASCII permitted in option names'
 
77
        out = self.run_bzr_error([error_re], ['st',u'-\xe4'])
63
78
 
64
79
 
65
80
class TestObsoleteRepoFormat(RepositoryFormat2a):
66
81
 
67
82
    @classmethod
68
83
    def get_format_string(cls):
69
 
        return b"Test Obsolete Repository Format"
 
84
        return "Test Obsolete Repository Format"
70
85
 
71
86
    def is_deprecated(self):
72
87
        return True
84
99
    def setUp(self):
85
100
        super(TestDeprecationWarning, self).setUp()
86
101
        self.addCleanup(repository.format_registry.remove,
87
 
                        TestObsoleteRepoFormat)
 
102
            TestObsoleteRepoFormat)
88
103
        repository.format_registry.register(TestObsoleteRepoFormat)
89
104
        self.addCleanup(controldir.format_registry.remove, "testobsolete")
90
105
        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.')
 
106
            "breezy.tests.blackbox.test_exceptions.TestObsoleteRepoFormat",
 
107
            branch_format='breezy.bzr.branch.BzrBranchFormat7',
 
108
            tree_format='breezy.bzr.workingtree_4.WorkingTreeFormat6',
 
109
            deprecated=True,
 
110
            help='Same as 2a, but with an obsolete repo format.')
96
111
        self.disable_deprecation_warning()
97
112
 
98
113
    def enable_deprecation_warning(self, repo=None):