diff options
author | Serhiy Storchaka <storchaka@gmail.com> | 2013-02-18 10:21:30 (GMT) |
---|---|---|
committer | Serhiy Storchaka <storchaka@gmail.com> | 2013-02-18 10:21:30 (GMT) |
commit | 407aa2df2aa81180df611148fbfe7a7f57673a74 (patch) | |
tree | 06e1395d9534ba27344ed479a32794a05f76cfe9 /Lib/test/test_posixpath.py | |
parent | f844f7e361bd23358d511bb74c71b01c5207e191 (diff) | |
parent | 467393dff5666b87eafe46660abf6ea0e2018c64 (diff) | |
download | cpython-407aa2df2aa81180df611148fbfe7a7f57673a74.zip cpython-407aa2df2aa81180df611148fbfe7a7f57673a74.tar.gz cpython-407aa2df2aa81180df611148fbfe7a7f57673a74.tar.bz2 |
Fix posixpath.realpath() for multiple pardirs (fixes issue #6975).
Diffstat (limited to 'Lib/test/test_posixpath.py')
-rw-r--r-- | Lib/test/test_posixpath.py | 18 |
1 files changed, 18 insertions, 0 deletions
diff --git a/Lib/test/test_posixpath.py b/Lib/test/test_posixpath.py index 3af9175..01d84da 100644 --- a/Lib/test/test_posixpath.py +++ b/Lib/test/test_posixpath.py @@ -340,6 +340,24 @@ class PosixPathTest(unittest.TestCase): self.assertEqual(posixpath.normpath(b"///..//./foo/.//bar"), b"/foo/bar") + def test_realpath_curdir(self): + self.assertEqual(realpath('.'), os.getcwd()) + self.assertEqual(realpath('./.'), os.getcwd()) + self.assertEqual(realpath('/'.join(['.'] * 100)), os.getcwd()) + + self.assertEqual(realpath(b'.'), os.getcwdb()) + self.assertEqual(realpath(b'./.'), os.getcwdb()) + self.assertEqual(realpath(b'/'.join([b'.'] * 100)), os.getcwdb()) + + def test_realpath_pardir(self): + self.assertEqual(realpath('..'), dirname(os.getcwd())) + self.assertEqual(realpath('../..'), dirname(dirname(os.getcwd()))) + self.assertEqual(realpath('/'.join(['..'] * 100)), '/') + + self.assertEqual(realpath(b'..'), dirname(os.getcwdb())) + self.assertEqual(realpath(b'../..'), dirname(dirname(os.getcwdb()))) + self.assertEqual(realpath(b'/'.join([b'..'] * 100)), b'/') + @unittest.skipUnless(hasattr(os, "symlink"), "Missing symlink implementation") @skip_if_ABSTFN_contains_backslash |