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

  • Committer: Marius Kruger
  • Date: 2010-07-10 21:28:56 UTC
  • mto: (5384.1.1 integration)
  • mto: This revision was merged to the branch mainline in revision 5385.
  • Revision ID: marius.kruger@enerweb.co.za-20100710212856-uq4ji3go0u5se7hx
* Update documentation
* add NEWS

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
# Copyright (C) 2005, 2006, 2008, 2009, 2011 Canonical Ltd
 
1
# Copyright (C) 2005 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 .. import osutils
24
 
from ..osutils import pathjoin
25
 
from . import TestCase, TestCaseWithTransport, TestSkipped
 
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
26
27
 
27
28
 
28
29
class NonAsciiTest(TestCaseWithTransport):
35
36
        except UnicodeEncodeError:
36
37
            raise TestSkipped("filesystem can't accomodate nonascii names")
37
38
            return
38
 
        with open(pathjoin(br_dir, "a"), "w") as f:
39
 
            f.write("hello")
40
 
        wt.add(["a"], [b"a-id"])
 
39
        file(pathjoin(br_dir, "a"), "w").write("hello")
 
40
        wt.add(["a"], ["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(
127
 
                [a_circle_d + '.1', a_dots_d + '.2', z_umlat_d + '.3'])
 
126
            expected = sorted([a_circle_d+'.1', a_dots_d+'.2', z_umlat_d+'.3'])
128
127
        else:
129
128
            expected = sorted(files)
130
129
 
138
137
        # a_circle_c and a_dots_c actually map to the same file
139
138
        # adding a suffix kicks in the 'preserving but insensitive'
140
139
        # route, and maintains the right files
141
 
        files = [a_circle_c + '.1', a_dots_c + '.2', z_umlat_c + '.3',
142
 
                 squared_c + '.4', quarter_c + '.5']
 
140
        files = [a_circle_c+'.1', a_dots_c+'.2', z_umlat_c+'.3',
 
141
                 squared_c+'.4', quarter_c+'.5']
143
142
        try:
144
143
            self.build_tree(files, line_endings='native')
145
144
        except UnicodeError:
153
152
            self.assertEqual(path, fname)
154
153
            self.assertTrue(can_access)
155
154
 
156
 
            with open(path, 'rb') as f:
 
155
            f = open(path, 'rb')
 
156
            try:
157
157
                # Check the contents
158
 
                shouldbe = b'contents of %s%s' % (path.encode('utf8'),
159
 
                                                  os.linesep.encode('utf-8'))
 
158
                shouldbe = 'contents of %s%s' % (path.encode('utf8'),
 
159
                                                 os.linesep)
160
160
                actual = f.read()
 
161
            finally:
 
162
                f.close()
161
163
            self.assertEqual(shouldbe, actual,
162
164
                             'contents of %r is incorrect: %r != %r'
163
165
                             % (path, shouldbe, actual))
165
167
    def test_access_non_normalized(self):
166
168
        # Sometimes we can access non-normalized files by their normalized
167
169
        # path, verify that normalized_filename returns the right info
168
 
        files = [a_circle_d + '.1', a_dots_d + '.2', z_umlat_d + '.3']
 
170
        files = [a_circle_d+'.1', a_dots_d+'.2', z_umlat_d+'.3']
169
171
 
170
172
        try:
171
173
            self.build_tree(files)