Back to index

python3.2  3.2.2
Public Member Functions | Private Member Functions
test.test_unicode_file.TestUnicodeFiles Class Reference

List of all members.

Public Member Functions

def test_single_files
def test_directories

Private Member Functions

def _do_single
def _do_copyish
def _do_directory
def _test_single

Detailed Description

Definition at line 23 of file test_unicode_file.py.


Member Function Documentation

def test.test_unicode_file.TestUnicodeFiles._do_copyish (   self,
  filename1,
  filename2 
) [private]

Definition at line 55 of file test_unicode_file.py.

00055 
00056     def _do_copyish(self, filename1, filename2):
00057         # Should be able to rename the file using either name.
00058         self.assertTrue(os.path.isfile(filename1)) # must exist.
00059         os.rename(filename1, filename2 + ".new")
00060         self.assertTrue(os.path.isfile(filename1+".new"))
00061         os.rename(filename1 + ".new", filename2)
00062         self.assertTrue(os.path.isfile(filename2))
00063 
00064         shutil.copy(filename1, filename2 + ".new")
00065         os.unlink(filename1 + ".new") # remove using equiv name.
00066         # And a couple of moves, one using each name.
00067         shutil.move(filename1, filename2 + ".new")
00068         self.assertTrue(not os.path.exists(filename2))
00069         shutil.move(filename1 + ".new", filename2)
00070         self.assertTrue(os.path.exists(filename1))
00071         # Note - due to the implementation of shutil.move,
00072         # it tries a rename first.  This only fails on Windows when on
00073         # different file systems - and this test can't ensure that.
00074         # So we test the shutil.copy2 function, which is the thing most
00075         # likely to fail.
00076         shutil.copy2(filename1, filename2 + ".new")
00077         os.unlink(filename1 + ".new")

Here is the call graph for this function:

Here is the caller graph for this function:

def test.test_unicode_file.TestUnicodeFiles._do_directory (   self,
  make_name,
  chdir_name 
) [private]

Definition at line 78 of file test_unicode_file.py.

00078 
00079     def _do_directory(self, make_name, chdir_name):
00080         cwd = os.getcwdb()
00081         if os.path.isdir(make_name):
00082             rmtree(make_name)
00083         os.mkdir(make_name)
00084         try:
00085             os.chdir(chdir_name)
00086             try:
00087                 cwd_result = os.getcwd()
00088                 name_result = make_name
00089 
00090                 cwd_result = unicodedata.normalize("NFD", cwd_result)
00091                 name_result = unicodedata.normalize("NFD", name_result)
00092 
00093                 self.assertEqual(os.path.basename(cwd_result),name_result)
00094             finally:
00095                 os.chdir(cwd)
00096         finally:
00097             os.rmdir(make_name)

Here is the call graph for this function:

Here is the caller graph for this function:

def test.test_unicode_file.TestUnicodeFiles._do_single (   self,
  filename 
) [private]

Definition at line 29 of file test_unicode_file.py.

00029 
00030     def _do_single(self, filename):
00031         self.assertTrue(os.path.exists(filename))
00032         self.assertTrue(os.path.isfile(filename))
00033         self.assertTrue(os.access(filename, os.R_OK))
00034         self.assertTrue(os.path.exists(os.path.abspath(filename)))
00035         self.assertTrue(os.path.isfile(os.path.abspath(filename)))
00036         self.assertTrue(os.access(os.path.abspath(filename), os.R_OK))
00037         os.chmod(filename, 0o777)
00038         os.utime(filename, None)
00039         os.utime(filename, (time.time(), time.time()))
00040         # Copy/rename etc tests using the same filename
00041         self._do_copyish(filename, filename)
00042         # Filename should appear in glob output
00043         self.assertTrue(
00044             os.path.abspath(filename)==os.path.abspath(glob.glob(filename)[0]))
00045         # basename should appear in listdir.
00046         path, base = os.path.split(os.path.abspath(filename))
00047         file_list = os.listdir(path)
00048         # Normalize the unicode strings, as round-tripping the name via the OS
00049         # may return a different (but equivalent) value.
00050         base = unicodedata.normalize("NFD", base)
00051         file_list = [unicodedata.normalize("NFD", f) for f in file_list]
00052 
00053         self.assertIn(base, file_list)

Here is the call graph for this function:

Here is the caller graph for this function:

def test.test_unicode_file.TestUnicodeFiles._test_single (   self,
  filename 
) [private]

Definition at line 100 of file test_unicode_file.py.

00100 
00101     def _test_single(self, filename):
00102         remove_if_exists(filename)
00103         f = open(filename, "w")
00104         f.close()
00105         try:
00106             self._do_single(filename)
00107         finally:
00108             os.unlink(filename)
00109         self.assertTrue(not os.path.exists(filename))
00110         # and again with os.open.
00111         f = os.open(filename, os.O_CREAT)
00112         os.close(f)
00113         try:
00114             self._do_single(filename)
00115         finally:
00116             os.unlink(filename)

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 124 of file test_unicode_file.py.

00124 
00125     def test_directories(self):
00126         # For all 'equivalent' combinations:
00127         #  Make dir with encoded, chdir with unicode, checkdir with encoded
00128         #  (or unicode/encoded/unicode, etc
00129         ext = ".dir"
00130         self._do_directory(TESTFN_UNICODE+ext, TESTFN_UNICODE+ext)
00131         # Our directory name that can't use a non-unicode name.
00132         if TESTFN_UNENCODABLE is not None:
00133             self._do_directory(TESTFN_UNENCODABLE+ext,
00134                                TESTFN_UNENCODABLE+ext)

Here is the call graph for this function:

Definition at line 119 of file test_unicode_file.py.

00119 
00120     def test_single_files(self):
00121         self._test_single(TESTFN_UNICODE)
00122         if TESTFN_UNENCODABLE is not None:
00123             self._test_single(TESTFN_UNENCODABLE)

Here is the call graph for this function:


The documentation for this class was generated from the following file: