From c7fff3467f7f8abfcec09744e60c597f51719a63 Mon Sep 17 00:00:00 2001 From: Georg Brandl Date: Fri, 3 Jun 2005 14:28:50 +0000 Subject: Bug #1213894: os.path.realpath didn't resolve symlinks that were the first component of the path. --- Lib/test/test_posixpath.py | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) (limited to 'Lib/test/test_posixpath.py') diff --git a/Lib/test/test_posixpath.py b/Lib/test/test_posixpath.py index 0a6ed9903e..b2d8d406b7 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): -- cgit v1.2.1