| OLD | NEW |
| 1 # Test some Unicode file name semantics | 1 # Test some Unicode file name semantics |
| 2 # We dont test many operations on files other than | 2 # We dont test many operations on files other than |
| 3 # that their names can be used with Unicode characters. | 3 # that their names can be used with Unicode characters. |
| 4 import os, glob, time, shutil | 4 import os, glob, time, shutil |
| 5 import unicodedata | 5 import unicodedata |
| 6 | 6 |
| 7 import unittest | 7 import unittest |
| 8 from test.support import run_unittest, TestSkipped, TESTFN_UNICODE | 8 from test.support import run_unittest, TestSkipped, TESTFN_UNICODE |
| 9 from test.support import TESTFN_ENCODING, TESTFN_UNICODE_UNENCODEABLE | 9 from test.support import TESTFN_ENCODING, TESTFN_UNICODE_UNENCODEABLE |
| 10 try: | 10 try: |
| (...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 83 self.failUnless(os.path.exists(filename1)) | 83 self.failUnless(os.path.exists(filename1)) |
| 84 # Note - due to the implementation of shutil.move, | 84 # Note - due to the implementation of shutil.move, |
| 85 # it tries a rename first. This only fails on Windows when on | 85 # it tries a rename first. This only fails on Windows when on |
| 86 # different file systems - and this test can't ensure that. | 86 # different file systems - and this test can't ensure that. |
| 87 # So we test the shutil.copy2 function, which is the thing most | 87 # So we test the shutil.copy2 function, which is the thing most |
| 88 # likely to fail. | 88 # likely to fail. |
| 89 shutil.copy2(filename1, filename2 + ".new") | 89 shutil.copy2(filename1, filename2 + ".new") |
| 90 os.unlink(filename1 + ".new") | 90 os.unlink(filename1 + ".new") |
| 91 | 91 |
| 92 def _do_directory(self, make_name, chdir_name, encoded): | 92 def _do_directory(self, make_name, chdir_name, encoded): |
| 93 cwd = os.getcwd() | 93 cwd = os.getcwdb() |
| 94 if os.path.isdir(make_name): | 94 if os.path.isdir(make_name): |
| 95 os.rmdir(make_name) | 95 os.rmdir(make_name) |
| 96 os.mkdir(make_name) | 96 os.mkdir(make_name) |
| 97 try: | 97 try: |
| 98 os.chdir(chdir_name) | 98 os.chdir(chdir_name) |
| 99 try: | 99 try: |
| 100 if not encoded: | 100 if not encoded: |
| 101 cwd_result = os.getcwdu() | 101 cwd_result = os.getcwd() |
| 102 name_result = make_name | 102 name_result = make_name |
| 103 else: | 103 else: |
| 104 cwd_result = os.getcwd().decode(TESTFN_ENCODING) | 104 cwd_result = os.getcwdb().decode(TESTFN_ENCODING) |
| 105 name_result = make_name.decode(TESTFN_ENCODING) | 105 name_result = make_name.decode(TESTFN_ENCODING) |
| 106 | 106 |
| 107 cwd_result = unicodedata.normalize("NFD", cwd_result) | 107 cwd_result = unicodedata.normalize("NFD", cwd_result) |
| 108 name_result = unicodedata.normalize("NFD", name_result) | 108 name_result = unicodedata.normalize("NFD", name_result) |
| 109 | 109 |
| 110 self.failUnlessEqual(os.path.basename(cwd_result),name_result) | 110 self.failUnlessEqual(os.path.basename(cwd_result),name_result) |
| 111 finally: | 111 finally: |
| 112 os.chdir(cwd) | 112 os.chdir(cwd) |
| 113 finally: | 113 finally: |
| 114 os.rmdir(make_name) | 114 os.rmdir(make_name) |
| (...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 159 if TESTFN_UNICODE_UNENCODEABLE is not None: | 159 if TESTFN_UNICODE_UNENCODEABLE is not None: |
| 160 self._do_directory(TESTFN_UNICODE_UNENCODEABLE+ext, | 160 self._do_directory(TESTFN_UNICODE_UNENCODEABLE+ext, |
| 161 TESTFN_UNICODE_UNENCODEABLE+ext, | 161 TESTFN_UNICODE_UNENCODEABLE+ext, |
| 162 False) | 162 False) |
| 163 | 163 |
| 164 def test_main(): | 164 def test_main(): |
| 165 run_unittest(__name__) | 165 run_unittest(__name__) |
| 166 | 166 |
| 167 if __name__ == "__main__": | 167 if __name__ == "__main__": |
| 168 test_main() | 168 test_main() |
| OLD | NEW |