17
17
"""Test that various operations work in a non-ASCII environment."""
21
from unicodedata import normalize
23
from bzrlib.branch import Branch
24
from bzrlib.osutils import normalizes_filenames, unicode_filename
21
25
from bzrlib.tests import TestCaseInTempDir
22
from bzrlib.branch import Branch
25
28
class NonAsciiTest(TestCaseInTempDir):
36
39
br = Branch.initialize(u".")
37
40
file("a", "w").write("hello")
38
41
br.working_tree().add(["a"], ["a-id"])
46
a_circle_d = u'a\u030a'
49
z_umlat_d = u'Z\u030c'
52
class UnicodeFilename(TestCaseInTempDir):
53
"""Test that UnicodeFilename returns the expected values."""
55
def test_a_circle(self):
56
self.assertEqual(a_circle_d, normalize('NFKD', a_circle_c))
57
self.assertEqual(a_circle_c, normalize('NFKC', a_circle_d))
59
self.assertEqual((a_circle_c, True), unicode_filename(a_circle_c))
60
if normalizes_filenames():
61
self.assertEqual((a_circle_c, True), unicode_filename(a_circle_d))
63
self.assertEqual((a_circle_d, False), unicode_filename(a_circle_d))
65
def test_platform(self):
66
self.build_tree([a_circle_c, a_dots_c, z_umlat_c])
68
if sys.platform == 'darwin':
69
expected = sorted([a_circle_d, a_dots_d, z_umlat_d])
71
expected = sorted([a_circle_c, a_dots_c, z_umlat_c])
73
present = sorted(os.listdir(u'.'))
74
self.assertEqual(expected, present)
76
def test_access(self):
77
# We should always be able to access files by the path returned
78
# from unicode_filename
79
files = [a_circle_c, a_dots_c, z_umlat_c]
80
self.build_tree(files)
83
path = unicode_filename(fname)[0]
84
# We should get an exception if we can't open the file at