mirror of
https://github.com/python/cpython.git
synced 2025-07-30 06:34:15 +00:00
Patch 1339796: add a relpath() function to os.path.
This commit is contained in:
parent
6de691d78c
commit
6f187743ff
7 changed files with 77 additions and 3 deletions
|
@ -157,6 +157,16 @@ except ImportError:
|
|||
else:
|
||||
tester('ntpath.abspath("C:\\")', "C:\\")
|
||||
|
||||
currentdir = os.path.split(os.getcwd())[-1]
|
||||
tester('ntpath.relpath("a")', 'a')
|
||||
tester('ntpath.relpath(os.path.abspath("a"))', 'a')
|
||||
tester('ntpath.relpath("a/b")', 'a\\b')
|
||||
tester('ntpath.relpath("../a/b")', '..\\a\\b')
|
||||
tester('ntpath.relpath("a", "../b")', '..\\'+currentdir+'\\a')
|
||||
tester('ntpath.relpath("a/b", "../c")', '..\\'+currentdir+'\\a\\b')
|
||||
tester('ntpath.relpath("a", "b/c")', '..\\..\\a')
|
||||
tester('ntpath.relpath("//conky/mountpoint/a", "//conky/mountpoint/b/c")', '..\\..\\a')
|
||||
|
||||
if errors:
|
||||
raise TestFailed(str(errors) + " errors.")
|
||||
elif verbose:
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue