Rietveld Code Review Tool
Help | Bug tracker | Discussion group | Source code | Sign in
(160749)

Side by Side Diff: Lib/test/test_pep277.py

Issue 23670: Modifications to support iOS as a development platform
Patch Set: Created 3 years, 9 months ago
Left:
Right:
Use n/p to move between diff chunks; N/P to move between comments. Please Sign in to add in-line comments.
Jump to:
View unified diff | Download patch
« no previous file with comments | « Lib/test/test_pdb.py ('k') | Lib/test/test_pipes.py » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 # Test the Unicode versions of normal file functions 1 # Test the Unicode versions of normal file functions
2 # open, os.open, os.stat. os.listdir, os.rename, os.remove, os.mkdir, os.chdir, os.rmdir 2 # open, os.open, os.stat. os.listdir, os.rename, os.remove, os.mkdir, os.chdir, os.rmdir
3 import os 3 import os
4 import sys 4 import sys
5 import unittest 5 import unittest
6 import warnings 6 import warnings
7 from unicodedata import normalize 7 from unicodedata import normalize
8 from test import support 8 from test import support
9 9
10 filenames = [ 10 filenames = [
11 '1_abc', 11 '1_abc',
12 '2_ascii', 12 '2_ascii',
13 '3_Gr\xfc\xdf-Gott', 13 '3_Gr\xfc\xdf-Gott',
14 '4_\u0393\u03b5\u03b9\u03ac-\u03c3\u03b1\u03c2', 14 '4_\u0393\u03b5\u03b9\u03ac-\u03c3\u03b1\u03c2',
15 '5_\u0417\u0434\u0440\u0430\u0432\u0441\u0442\u0432\u0443\u0439\u0442\u0435' , 15 '5_\u0417\u0434\u0440\u0430\u0432\u0441\u0442\u0432\u0443\u0439\u0442\u0435' ,
16 '6_\u306b\u307d\u3093', 16 '6_\u306b\u307d\u3093',
17 '7_\u05d4\u05e9\u05e7\u05e6\u05e5\u05e1', 17 '7_\u05d4\u05e9\u05e7\u05e6\u05e5\u05e1',
18 '8_\u66e8\u66e9\u66eb', 18 '8_\u66e8\u66e9\u66eb',
19 '9_\u66e8\u05e9\u3093\u0434\u0393\xdf', 19 '9_\u66e8\u05e9\u3093\u0434\u0393\xdf',
20 # Specific code points: fn, NFC(fn) and NFKC(fn) all differents 20 # Specific code points: fn, NFC(fn) and NFKC(fn) all differents
21 '10_\u1fee\u1ffd', 21 '10_\u1fee\u1ffd',
22 ] 22 ]
23 23
24 # Mac OS X decomposes Unicode names, using Normal Form D. 24 # Mac OS X decomposes Unicode names, using Normal Form D.
25 # http://developer.apple.com/mac/library/qa/qa2001/qa1173.html 25 # http://developer.apple.com/mac/library/qa/qa2001/qa1173.html
26 # "However, most volume formats do not follow the exact specification for 26 # "However, most volume formats do not follow the exact specification for
27 # these normal forms. For example, HFS Plus uses a variant of Normal Form D 27 # these normal forms. For example, HFS Plus uses a variant of Normal Form D
28 # in which U+2000 through U+2FFF, U+F900 through U+FAFF, and U+2F800 through 28 # in which U+2000 through U+2FFF, U+F900 through U+FAFF, and U+2F800 through
29 # U+2FAFF are not decomposed." 29 # U+2FAFF are not decomposed."
30 if sys.platform != 'darwin': 30 if sys.platform not in ('darwin', 'ios'):
31 filenames.extend([ 31 filenames.extend([
32 # Specific code points: NFC(fn), NFD(fn), NFKC(fn) and NFKD(fn) all diff erents 32 # Specific code points: NFC(fn), NFD(fn), NFKC(fn) and NFKD(fn) all diff erents
33 '11_\u0385\u03d3\u03d4', 33 '11_\u0385\u03d3\u03d4',
34 '12_\u00a8\u0301\u03d2\u0301\u03d2\u0308', # == NFD('\u0385\u03d3\u03d4' ) 34 '12_\u00a8\u0301\u03d2\u0301\u03d2\u0308', # == NFD('\u0385\u03d3\u03d4' )
35 '13_\u0020\u0308\u0301\u038e\u03ab', # == NFKC('\u0385\u03d3\u03d4 ') 35 '13_\u0020\u0308\u0301\u038e\u03ab', # == NFKC('\u0385\u03d3\u03d4 ')
36 '14_\u1e9b\u1fc1\u1fcd\u1fce\u1fcf\u1fdd\u1fde\u1fdf\u1fed', 36 '14_\u1e9b\u1fc1\u1fcd\u1fce\u1fcf\u1fdd\u1fde\u1fdf\u1fed',
37 37
38 # Specific code points: fn, NFC(fn) and NFKC(fn) all differents 38 # Specific code points: fn, NFC(fn) and NFKC(fn) all differents
39 '15_\u1fee\u1ffd\ufad1', 39 '15_\u1fee\u1ffd\ufad1',
40 '16_\u2000\u2000\u2000A', 40 '16_\u2000\u2000\u2000A',
(...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after
110 _listdir_failure = NotADirectoryError 110 _listdir_failure = NotADirectoryError
111 111
112 def test_open(self): 112 def test_open(self):
113 for name in self.files: 113 for name in self.files:
114 f = open(name, 'wb') 114 f = open(name, 'wb')
115 f.write((name+'\n').encode("utf-8")) 115 f.write((name+'\n').encode("utf-8"))
116 f.close() 116 f.close()
117 os.stat(name) 117 os.stat(name)
118 self._apply_failure(os.listdir, name, self._listdir_failure) 118 self._apply_failure(os.listdir, name, self._listdir_failure)
119 119
120 # Skip the test on darwin, because darwin does normalize the filename to 120 # Skip the test on darwin/iOS, because darwin does normalize the filename to
121 # NFD (a variant of Unicode NFD form). Normalize the filename to NFC, NFKC, 121 # NFD (a variant of Unicode NFD form). Normalize the filename to NFC, NFKC,
122 # NFKD in Python is useless, because darwin will normalize it later and so 122 # NFKD in Python is useless, because darwin will normalize it later and so
123 # open(), os.stat(), etc. don't raise any exception. 123 # open(), os.stat(), etc. don't raise any exception.
124 @unittest.skipIf(sys.platform == 'darwin', 'irrelevant test on Mac OS X') 124 @unittest.skipIf(sys.platform in ('darwin', 'ios'), 'irrelevant test on Mac OS X')
125 def test_normalize(self): 125 def test_normalize(self):
126 files = set(self.files) 126 files = set(self.files)
127 others = set() 127 others = set()
128 for nf in set(['NFC', 'NFD', 'NFKC', 'NFKD']): 128 for nf in set(['NFC', 'NFD', 'NFKC', 'NFKD']):
129 others |= set(normalize(nf, file) for file in files) 129 others |= set(normalize(nf, file) for file in files)
130 others -= files 130 others -= files
131 for name in others: 131 for name in others:
132 self._apply_failure(open, name) 132 self._apply_failure(open, name)
133 self._apply_failure(os.stat, name) 133 self._apply_failure(os.stat, name)
134 self._apply_failure(os.chdir, name) 134 self._apply_failure(os.chdir, name)
135 self._apply_failure(os.rmdir, name) 135 self._apply_failure(os.rmdir, name)
136 self._apply_failure(os.remove, name) 136 self._apply_failure(os.remove, name)
137 self._apply_failure(os.listdir, name) 137 self._apply_failure(os.listdir, name)
138 138
139 # Skip the test on darwin, because darwin uses a normalization different 139 # Skip the test on darwin/iOS, because darwin uses a normalization different
140 # than Python NFD normalization: filenames are different even if we use 140 # than Python NFD normalization: filenames are different even if we use
141 # Python NFD normalization. 141 # Python NFD normalization.
142 @unittest.skipIf(sys.platform == 'darwin', 'irrelevant test on Mac OS X') 142 @unittest.skipIf(sys.platform in ('darwin', 'ios'), 'irrelevant test on Mac OS X')
143 def test_listdir(self): 143 def test_listdir(self):
144 sf0 = set(self.files) 144 sf0 = set(self.files)
145 with warnings.catch_warnings(): 145 with warnings.catch_warnings():
146 warnings.simplefilter("ignore", DeprecationWarning) 146 warnings.simplefilter("ignore", DeprecationWarning)
147 f1 = os.listdir(support.TESTFN.encode(sys.getfilesystemencoding())) 147 f1 = os.listdir(support.TESTFN.encode(sys.getfilesystemencoding()))
148 f2 = os.listdir(support.TESTFN) 148 f2 = os.listdir(support.TESTFN)
149 sf2 = set(os.path.join(support.TESTFN, f) for f in f2) 149 sf2 = set(os.path.join(support.TESTFN, f) for f in f2)
150 self.assertEqual(sf0, sf2, "%a != %a" % (sf0, sf2)) 150 self.assertEqual(sf0, sf2, "%a != %a" % (sf0, sf2))
151 self.assertEqual(len(f1), len(f2)) 151 self.assertEqual(len(f1), len(f2))
152 152
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
186 UnicodeFileTests, 186 UnicodeFileTests,
187 UnicodeNFCFileTests, 187 UnicodeNFCFileTests,
188 UnicodeNFDFileTests, 188 UnicodeNFDFileTests,
189 UnicodeNFKCFileTests, 189 UnicodeNFKCFileTests,
190 UnicodeNFKDFileTests, 190 UnicodeNFKDFileTests,
191 ) 191 )
192 192
193 193
194 if __name__ == "__main__": 194 if __name__ == "__main__":
195 test_main() 195 test_main()
OLDNEW
« no previous file with comments | « Lib/test/test_pdb.py ('k') | Lib/test/test_pipes.py » ('j') | no next file with comments »

RSS Feeds Recent Issues | This issue
This is Rietveld 894c83f36cb7+