/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-04-05 19:11:34 UTC
  • mto: (7490.7.16 work)
  • mto: This revision was merged to the branch mainline in revision 7501.
  • Revision ID: jelmer@jelmer.uk-20200405191134-0aebh8ikiwygxma5
Populate the .gitignore file.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
# Copyright (C) 2005 Canonical Ltd
 
1
# Copyright (C) 2005, 2006, 2008, 2009, 2011 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
20
20
import sys
21
21
from unicodedata import normalize
22
22
 
23
 
from bzrlib import osutils
24
 
from bzrlib.osutils import pathjoin
25
 
from bzrlib.tests import TestCase, TestCaseWithTransport, TestSkipped
26
 
from bzrlib.workingtree import WorkingTree
 
23
from .. import osutils
 
24
from ..osutils import pathjoin
 
25
from . import TestCase, TestCaseWithTransport, TestSkipped
27
26
 
28
27
 
29
28
class NonAsciiTest(TestCaseWithTransport):
36
35
        except UnicodeEncodeError:
37
36
            raise TestSkipped("filesystem can't accomodate nonascii names")
38
37
            return
39
 
        file(pathjoin(br_dir, "a"), "w").write("hello")
40
 
        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"])
41
41
 
42
42
 
43
43
a_circle_c = u'\xe5'
46
46
a_dots_d = u'a\u0308'
47
47
z_umlat_c = u'\u017d'
48
48
z_umlat_d = u'Z\u030c'
49
 
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]
50
50
squared_d = u'\xbc'
51
 
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]
52
52
quarter_d = u'\xb2'
53
53
 
54
54
 
116
116
        # a_circle_c and a_dots_c actually map to the same file
117
117
        # adding a suffix kicks in the 'preserving but insensitive'
118
118
        # route, and maintains the right files
119
 
        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']
120
120
        try:
121
121
            self.build_tree(files)
122
122
        except UnicodeError:
123
123
            raise TestSkipped("filesystem cannot create unicode files")
124
124
 
125
125
        if sys.platform == 'darwin':
126
 
            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'])
127
128
        else:
128
129
            expected = sorted(files)
129
130
 
137
138
        # a_circle_c and a_dots_c actually map to the same file
138
139
        # adding a suffix kicks in the 'preserving but insensitive'
139
140
        # route, and maintains the right files
140
 
        files = [a_circle_c+'.1', a_dots_c+'.2', z_umlat_c+'.3',
141
 
                 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']
142
143
        try:
143
144
            self.build_tree(files, line_endings='native')
144
145
        except UnicodeError:
152
153
            self.assertEqual(path, fname)
153
154
            self.assertTrue(can_access)
154
155
 
155
 
            f = open(path, 'rb')
156
 
            try:
 
156
            with open(path, 'rb') as f:
157
157
                # Check the contents
158
 
                shouldbe = 'contents of %s%s' % (path.encode('utf8'),
159
 
                                                 os.linesep)
 
158
                shouldbe = b'contents of %s%s' % (path.encode('utf8'),
 
159
                                                  os.linesep.encode('utf-8'))
160
160
                actual = f.read()
161
 
            finally:
162
 
                f.close()
163
161
            self.assertEqual(shouldbe, actual,
164
162
                             'contents of %r is incorrect: %r != %r'
165
163
                             % (path, shouldbe, actual))
167
165
    def test_access_non_normalized(self):
168
166
        # Sometimes we can access non-normalized files by their normalized
169
167
        # path, verify that normalized_filename returns the right info
170
 
        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']
171
169
 
172
170
        try:
173
171
            self.build_tree(files)