~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/tests/test_osutils.py

Merge propagate-exceptions into http-leaks

Show diffs side-by-side

added added

removed removed

Lines of Context:
1083
1083
        # Ensure the message contains the file name
1084
1084
        self.assertContainsRe(str(e), "\./test-unreadable")
1085
1085
 
 
1086
 
 
1087
    def test_walkdirs_encoding_error(self):
 
1088
        # <https://bugs.launchpad.net/bzr/+bug/488519>
 
1089
        # walkdirs didn't raise a useful message when the filenames
 
1090
        # are not using the filesystem's encoding
 
1091
 
 
1092
        # require a bytestring based filesystem
 
1093
        self.requireFeature(tests.ByteStringNamedFilesystem)
 
1094
 
 
1095
        tree = [
 
1096
            '.bzr',
 
1097
            '0file',
 
1098
            '1dir/',
 
1099
            '1dir/0file',
 
1100
            '1dir/1dir/',
 
1101
            '1file'
 
1102
            ]
 
1103
 
 
1104
        self.build_tree(tree)
 
1105
 
 
1106
        # rename the 1file to a latin-1 filename
 
1107
        os.rename("./1file", "\xe8file")
 
1108
 
 
1109
        self._save_platform_info()
 
1110
        win32utils.winver = None # Avoid the win32 detection code
 
1111
        osutils._fs_enc = 'UTF-8'
 
1112
 
 
1113
        # this should raise on error
 
1114
        def attempt():
 
1115
            for dirdetail, dirblock in osutils.walkdirs('.'):
 
1116
                pass
 
1117
 
 
1118
        self.assertRaises(errors.BadFilenameEncoding, attempt)
 
1119
 
1086
1120
    def test__walkdirs_utf8(self):
1087
1121
        tree = [
1088
1122
            '.bzr',
1921
1955
    def restore_osutils_globals(self):
1922
1956
        osutils._terminal_size_state = self._orig_terminal_size_state
1923
1957
        osutils._first_terminal_size = self._orig_first_terminal_size
1924
 
        
 
1958
 
1925
1959
    def replace_stdout(self, new):
1926
1960
        self.overrideAttr(sys, 'stdout', new)
1927
1961