summaryrefslogtreecommitdiffstats
path: root/Lib/test
diff options
context:
space:
mode:
authorGeorg Brandl <georg@python.org>2005-06-03 14:28:50 (GMT)
committerGeorg Brandl <georg@python.org>2005-06-03 14:28:50 (GMT)
commit268e61cf7458d85d2e100480635390ebd480088f (patch)
tree62c42ea1bbe7be196808c7239d861f4a27075df8 /Lib/test
parent56616999950e151bed766a076e6a6b10f3492f8c (diff)
downloadcpython-268e61cf7458d85d2e100480635390ebd480088f.zip
cpython-268e61cf7458d85d2e100480635390ebd480088f.tar.gz
cpython-268e61cf7458d85d2e100480635390ebd480088f.tar.bz2
Bug #1213894: os.path.realpath didn't resolve symlinks that were the first
component of the path.
Diffstat (limited to 'Lib/test')
-rw-r--r--Lib/test/test_posixpath.py20
1 files changed, 20 insertions, 0 deletions
diff --git a/Lib/test/test_posixpath.py b/Lib/test/test_posixpath.py
index 0a6ed99..b2d8d40 100644
--- a/Lib/test/test_posixpath.py
+++ b/Lib/test/test_posixpath.py
@@ -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):