Back to index

python3.2  3.2.2
Public Member Functions | Static Public Attributes | Private Member Functions
test.test_os.Win32SymlinkTests Class Reference
Collaboration diagram for test.test_os.Win32SymlinkTests:
Collaboration graph
[legend]

List of all members.

Public Member Functions

def setUp
def tearDown
def test_directory_link
def test_file_link
def test_remove_directory_link_to_missing_target
def test_isdir_on_directory_link_to_missing_target
def test_rmdir_on_directory_link_to_missing_target
def check_stat
def test_12084

Static Public Attributes

string filelink = 'filelinktest'
tuple filelink_target = os.path.abspath(__file__)
string dirlink = 'dirlinktest'
tuple dirlink_target = os.path.dirname(filelink_target)
string missing_link = 'missing link'

Private Member Functions

def _create_missing_dir_link

Detailed Description

Definition at line 1072 of file test_os.py.


Member Function Documentation

Definition at line 1108 of file test_os.py.

01108 
01109     def _create_missing_dir_link(self):
01110         'Create a "directory" link to a non-existent target'
01111         linkname = self.missing_link
01112         if os.path.lexists(linkname):
01113             os.remove(linkname)
01114         target = r'c:\\target does not exist.29r3c740'
01115         assert not os.path.exists(target)
01116         target_is_dir = True
01117         os.symlink(target, linkname, target_is_dir)

Here is the caller graph for this function:

def test.test_os.Win32SymlinkTests.check_stat (   self,
  link,
  target 
)

Definition at line 1137 of file test_os.py.

01137 
01138     def check_stat(self, link, target):
01139         self.assertEqual(os.stat(link), os.stat(target))
01140         self.assertNotEqual(os.lstat(link), os.stat(link))
01141 
01142         bytes_link = os.fsencode(link)
01143         self.assertEqual(os.stat(bytes_link), os.stat(target))
01144         self.assertNotEqual(os.lstat(bytes_link), os.stat(bytes_link))

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 1079 of file test_os.py.

01079 
01080     def setUp(self):
01081         assert os.path.exists(self.dirlink_target)
01082         assert os.path.exists(self.filelink_target)
01083         assert not os.path.exists(self.dirlink)
01084         assert not os.path.exists(self.filelink)
01085         assert not os.path.exists(self.missing_link)

Here is the caller graph for this function:

Definition at line 1086 of file test_os.py.

01086 
01087     def tearDown(self):
01088         if os.path.exists(self.filelink):
01089             os.remove(self.filelink)
01090         if os.path.exists(self.dirlink):
01091             os.rmdir(self.dirlink)
01092         if os.path.lexists(self.missing_link):
01093             os.remove(self.missing_link)

Here is the caller graph for this function:

Definition at line 1145 of file test_os.py.

01145 
01146     def test_12084(self):
01147         level1 = os.path.abspath(support.TESTFN)
01148         level2 = os.path.join(level1, "level2")
01149         level3 = os.path.join(level2, "level3")
01150         try:
01151             os.mkdir(level1)
01152             os.mkdir(level2)
01153             os.mkdir(level3)
01154 
01155             file1 = os.path.abspath(os.path.join(level1, "file1"))
01156 
01157             with open(file1, "w") as f:
01158                 f.write("file1")
01159 
01160             orig_dir = os.getcwd()
01161             try:
01162                 os.chdir(level2)
01163                 link = os.path.join(level2, "link")
01164                 os.symlink(os.path.relpath(file1), "link")
01165                 self.assertIn("link", os.listdir(os.getcwd()))
01166 
01167                 # Check os.stat calls from the same dir as the link
01168                 self.assertEqual(os.stat(file1), os.stat("link"))
01169 
01170                 # Check os.stat calls from a dir below the link
01171                 os.chdir(level1)
01172                 self.assertEqual(os.stat(file1),
01173                                  os.stat(os.path.relpath(link)))
01174 
01175                 # Check os.stat calls from a dir above the link
01176                 os.chdir(level3)
01177                 self.assertEqual(os.stat(file1),
01178                                  os.stat(os.path.relpath(link)))
01179             finally:
01180                 os.chdir(orig_dir)
01181         except OSError as err:
01182             self.fail(err)
01183         finally:
01184             os.remove(file1)
01185             shutil.rmtree(level1)
01186 

Here is the call graph for this function:

Definition at line 1094 of file test_os.py.

01094 
01095     def test_directory_link(self):
01096         os.symlink(self.dirlink_target, self.dirlink)
01097         self.assertTrue(os.path.exists(self.dirlink))
01098         self.assertTrue(os.path.isdir(self.dirlink))
01099         self.assertTrue(os.path.islink(self.dirlink))
01100         self.check_stat(self.dirlink, self.dirlink_target)

Here is the call graph for this function:

Definition at line 1101 of file test_os.py.

01101 
01102     def test_file_link(self):
01103         os.symlink(self.filelink_target, self.filelink)
01104         self.assertTrue(os.path.exists(self.filelink))
01105         self.assertTrue(os.path.isfile(self.filelink))
01106         self.assertTrue(os.path.islink(self.filelink))
01107         self.check_stat(self.filelink, self.filelink_target)

Here is the call graph for this function:

Definition at line 1126 of file test_os.py.

01126 
01127     def test_isdir_on_directory_link_to_missing_target(self):
01128         self._create_missing_dir_link()
01129         # consider having isdir return true for directory links
01130         self.assertTrue(os.path.isdir(self.missing_link))

Here is the call graph for this function:

Definition at line 1118 of file test_os.py.

01118 
01119     def test_remove_directory_link_to_missing_target(self):
01120         self._create_missing_dir_link()
01121         # For compatibility with Unix, os.remove will check the
01122         #  directory status and call RemoveDirectory if the symlink
01123         #  was created with target_is_dir==True.
01124         os.remove(self.missing_link)

Here is the call graph for this function:

Definition at line 1132 of file test_os.py.

01132 
01133     def test_rmdir_on_directory_link_to_missing_target(self):
01134         self._create_missing_dir_link()
01135         # consider allowing rmdir to remove directory links
01136         os.rmdir(self.missing_link)

Here is the call graph for this function:


Member Data Documentation

Definition at line 1075 of file test_os.py.

Definition at line 1076 of file test_os.py.

Definition at line 1073 of file test_os.py.

tuple test.test_os.Win32SymlinkTests.filelink_target = os.path.abspath(__file__) [static]

Definition at line 1074 of file test_os.py.

Definition at line 1077 of file test_os.py.


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