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]
51
quarter_c = u'\xb2' # Gets mapped to u'1\u20444' (1/4) if we use NFK[CD]
51
55
class TestNormalization(TestCase):
52
56
"""Verify that we have our normalizations correct."""
54
58
def test_normalize(self):
55
self.assertEqual(a_circle_d, normalize('NFKD', a_circle_c))
56
self.assertEqual(a_circle_c, normalize('NFKC', a_circle_d))
57
self.assertEqual(a_dots_d, normalize('NFKD', a_dots_c))
58
self.assertEqual(a_dots_c, normalize('NFKC', a_dots_d))
59
self.assertEqual(z_umlat_d, normalize('NFKD', z_umlat_c))
60
self.assertEqual(z_umlat_c, normalize('NFKC', z_umlat_d))
59
self.assertEqual(a_circle_d, normalize('NFD', a_circle_c))
60
self.assertEqual(a_circle_c, normalize('NFC', a_circle_d))
61
self.assertEqual(a_dots_d, normalize('NFD', a_dots_c))
62
self.assertEqual(a_dots_c, normalize('NFC', a_dots_d))
63
self.assertEqual(z_umlat_d, normalize('NFD', z_umlat_c))
64
self.assertEqual(z_umlat_c, normalize('NFC', z_umlat_d))
65
self.assertEqual(squared_d, normalize('NFC', squared_c))
66
self.assertEqual(squared_c, normalize('NFD', squared_d))
67
self.assertEqual(quarter_d, normalize('NFC', quarter_c))
68
self.assertEqual(quarter_c, normalize('NFD', quarter_d))
63
71
class NormalizedFilename(TestCaseWithTransport):
74
82
self.assertEqual((a_dots_c, True), anf(a_dots_d))
75
83
self.assertEqual((z_umlat_c, True), anf(z_umlat_c))
76
84
self.assertEqual((z_umlat_c, True), anf(z_umlat_d))
85
self.assertEqual((squared_c, True), anf(squared_c))
86
self.assertEqual((squared_c, True), anf(squared_d))
87
self.assertEqual((quarter_c, True), anf(quarter_c))
88
self.assertEqual((quarter_c, True), anf(quarter_d))
78
90
def test__inaccessible_normalized_filename(self):
79
91
inf = osutils._inaccessible_normalized_filename
86
98
self.assertEqual((a_dots_c, False), inf(a_dots_d))
87
99
self.assertEqual((z_umlat_c, True), inf(z_umlat_c))
88
100
self.assertEqual((z_umlat_c, False), inf(z_umlat_d))
101
self.assertEqual((squared_c, True), inf(squared_c))
102
self.assertEqual((squared_c, True), inf(squared_d))
103
self.assertEqual((quarter_c, True), inf(quarter_c))
104
self.assertEqual((quarter_c, True), inf(quarter_d))
90
106
def test_functions(self):
91
107
if osutils.normalizes_filenames():
121
137
# a_circle_c and a_dots_c actually map to the same file
122
138
# adding a suffix kicks in the 'preserving but insensitive'
123
139
# route, and maintains the right files
124
files = [a_circle_c+'.1', a_dots_c+'.2', z_umlat_c+'.3']
140
files = [a_circle_c+'.1', a_dots_c+'.2', z_umlat_c+'.3',
141
squared_c+'.4', quarter_c+'.5']
126
143
self.build_tree(files, line_endings='native')
127
144
except UnicodeError: