/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/test_nonascii.py

  • Committer: Jelmer Vernooij
  • Date: 2020-05-06 02:13:25 UTC
  • mfrom: (7490.7.21 work)
  • mto: This revision was merged to the branch mainline in revision 7501.
  • Revision ID: jelmer@jelmer.uk-20200506021325-awbmmqu1zyorz7sj
Merge 3.1 branch.

Show diffs side-by-side

added added

removed removed

Lines of Context:
35
35
        except UnicodeEncodeError:
36
36
            raise TestSkipped("filesystem can't accomodate nonascii names")
37
37
            return
38
 
        with file(pathjoin(br_dir, "a"), "w") as f: f.write("hello")
39
 
        wt.add(["a"], ["a-id"])
 
38
        with open(pathjoin(br_dir, "a"), "w") as f:
 
39
            f.write("hello")
 
40
        wt.add(["a"], [b"a-id"])
40
41
 
41
42
 
42
43
a_circle_c = u'\xe5'
45
46
a_dots_d = u'a\u0308'
46
47
z_umlat_c = u'\u017d'
47
48
z_umlat_d = u'Z\u030c'
48
 
squared_c = u'\xbc' # This gets mapped to '2' if we use NFK[CD]
 
49
squared_c = u'\xbc'  # This gets mapped to '2' if we use NFK[CD]
49
50
squared_d = u'\xbc'
50
 
quarter_c = u'\xb2' # Gets mapped to u'1\u20444' (1/4) if we use NFK[CD]
 
51
quarter_c = u'\xb2'  # Gets mapped to u'1\u20444' (1/4) if we use NFK[CD]
51
52
quarter_d = u'\xb2'
52
53
 
53
54
 
115
116
        # a_circle_c and a_dots_c actually map to the same file
116
117
        # adding a suffix kicks in the 'preserving but insensitive'
117
118
        # route, and maintains the right files
118
 
        files = [a_circle_c+'.1', a_dots_c+'.2', z_umlat_c+'.3']
 
119
        files = [a_circle_c + '.1', a_dots_c + '.2', z_umlat_c + '.3']
119
120
        try:
120
121
            self.build_tree(files)
121
122
        except UnicodeError:
122
123
            raise TestSkipped("filesystem cannot create unicode files")
123
124
 
124
125
        if sys.platform == 'darwin':
125
 
            expected = sorted([a_circle_d+'.1', a_dots_d+'.2', z_umlat_d+'.3'])
 
126
            expected = sorted(
 
127
                [a_circle_d + '.1', a_dots_d + '.2', z_umlat_d + '.3'])
126
128
        else:
127
129
            expected = sorted(files)
128
130
 
136
138
        # a_circle_c and a_dots_c actually map to the same file
137
139
        # adding a suffix kicks in the 'preserving but insensitive'
138
140
        # route, and maintains the right files
139
 
        files = [a_circle_c+'.1', a_dots_c+'.2', z_umlat_c+'.3',
140
 
                 squared_c+'.4', quarter_c+'.5']
 
141
        files = [a_circle_c + '.1', a_dots_c + '.2', z_umlat_c + '.3',
 
142
                 squared_c + '.4', quarter_c + '.5']
141
143
        try:
142
144
            self.build_tree(files, line_endings='native')
143
145
        except UnicodeError:
151
153
            self.assertEqual(path, fname)
152
154
            self.assertTrue(can_access)
153
155
 
154
 
            f = open(path, 'rb')
155
 
            try:
 
156
            with open(path, 'rb') as f:
156
157
                # Check the contents
157
 
                shouldbe = 'contents of %s%s' % (path.encode('utf8'),
158
 
                                                 os.linesep)
 
158
                shouldbe = b'contents of %s%s' % (path.encode('utf8'),
 
159
                                                  os.linesep.encode('utf-8'))
159
160
                actual = f.read()
160
 
            finally:
161
 
                f.close()
162
161
            self.assertEqual(shouldbe, actual,
163
162
                             'contents of %r is incorrect: %r != %r'
164
163
                             % (path, shouldbe, actual))
166
165
    def test_access_non_normalized(self):
167
166
        # Sometimes we can access non-normalized files by their normalized
168
167
        # path, verify that normalized_filename returns the right info
169
 
        files = [a_circle_d+'.1', a_dots_d+'.2', z_umlat_d+'.3']
 
168
        files = [a_circle_d + '.1', a_dots_d + '.2', z_umlat_d + '.3']
170
169
 
171
170
        try:
172
171
            self.build_tree(files)