mirror of
https://github.com/python/cpython.git
synced 2025-08-03 16:39:00 +00:00
Bug #1213894: os.path.realpath didn't resolve symlinks that were the first
component of the path.
This commit is contained in:
parent
5661699995
commit
268e61cf74
3 changed files with 24 additions and 1 deletions
|
@ -476,6 +476,26 @@ class PosixPathTest(unittest.TestCase):
|
|||
self.safe_rmdir(ABSTFN + "/k/y")
|
||||
self.safe_rmdir(ABSTFN + "/k")
|
||||
self.safe_rmdir(ABSTFN)
|
||||
|
||||
def test_realpath_resolve_first(self):
|
||||
# Bug #1213894: The first component of the path, if not absolute,
|
||||
# must be resolved too.
|
||||
|
||||
try:
|
||||
old_path = abspath('.')
|
||||
os.mkdir(ABSTFN)
|
||||
os.mkdir(ABSTFN + "/k")
|
||||
os.symlink(ABSTFN, ABSTFN + "link")
|
||||
os.chdir(dirname(ABSTFN))
|
||||
|
||||
base = basename(ABSTFN)
|
||||
self.assertEqual(realpath(base + "link"), ABSTFN)
|
||||
self.assertEqual(realpath(base + "link/k"), ABSTFN + "/k")
|
||||
finally:
|
||||
os.chdir(old_path)
|
||||
self.safe_remove(ABSTFN + "link")
|
||||
self.safe_rmdir(ABSTFN + "/k")
|
||||
self.safe_rmdir(ABSTFN)
|
||||
|
||||
# Convenience functions for removing temporary files.
|
||||
def pass_os_error(self, func, filename):
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue