summaryrefslogtreecommitdiffstats
path: root/Lib/test/test_ntpath.py
diff options
context:
space:
mode:
authorSerhiy Storchaka <storchaka@gmail.com>2014-01-27 21:15:14 (GMT)
committerSerhiy Storchaka <storchaka@gmail.com>2014-01-27 21:15:14 (GMT)
commitc369c2c688c407433d88a7cad75cda88fbe799b5 (patch)
tree4b2952e461ada005e6e8b1953a6aef204af2ddff /Lib/test/test_ntpath.py
parent99e033b02e9f352c484e20d6a6d57954304865b4 (diff)
downloadcpython-c369c2c688c407433d88a7cad75cda88fbe799b5.zip
cpython-c369c2c688c407433d88a7cad75cda88fbe799b5.tar.gz
cpython-c369c2c688c407433d88a7cad75cda88fbe799b5.tar.bz2
Issue #19456: ntpath.join() now joins relative paths correctly when a drive
is present.
Diffstat (limited to 'Lib/test/test_ntpath.py')
-rw-r--r--Lib/test/test_ntpath.py67
1 files changed, 35 insertions, 32 deletions
diff --git a/Lib/test/test_ntpath.py b/Lib/test/test_ntpath.py
index b0f3011..2c4d27e 100644
--- a/Lib/test/test_ntpath.py
+++ b/Lib/test/test_ntpath.py
@@ -126,10 +126,7 @@ class TestNtpath(unittest.TestCase):
tester('ntpath.join("/a")', '/a')
tester('ntpath.join("\\a")', '\\a')
tester('ntpath.join("a:")', 'a:')
- tester('ntpath.join("a:", "b")', 'a:b')
- tester('ntpath.join("a:", "/b")', 'a:/b')
tester('ntpath.join("a:", "\\b")', 'a:\\b')
- tester('ntpath.join("a", "/b")', '/b')
tester('ntpath.join("a", "\\b")', '\\b')
tester('ntpath.join("a", "b", "c")', 'a\\b\\c')
tester('ntpath.join("a\\", "b", "c")', 'a\\b\\c')
@@ -137,42 +134,48 @@ class TestNtpath(unittest.TestCase):
tester('ntpath.join("a", "b", "\\c")', '\\c')
tester('ntpath.join("d:\\", "\\pleep")', 'd:\\pleep')
tester('ntpath.join("d:\\", "a", "b")', 'd:\\a\\b')
- tester("ntpath.join('c:', '/a')", 'c:/a')
- tester("ntpath.join('c:/', '/a')", 'c:/a')
- tester("ntpath.join('c:/a', '/b')", '/b')
- tester("ntpath.join('c:', 'd:/')", 'd:/')
- tester("ntpath.join('c:/', 'd:/')", 'd:/')
- tester("ntpath.join('c:/', 'd:/a/b')", 'd:/a/b')
-
- tester("ntpath.join('')", '')
- tester("ntpath.join('', '', '', '', '')", '')
- tester("ntpath.join('a')", 'a')
+
tester("ntpath.join('', 'a')", 'a')
tester("ntpath.join('', '', '', '', 'a')", 'a')
tester("ntpath.join('a', '')", 'a\\')
tester("ntpath.join('a', '', '', '', '')", 'a\\')
tester("ntpath.join('a\\', '')", 'a\\')
tester("ntpath.join('a\\', '', '', '', '')", 'a\\')
+ tester("ntpath.join('a/', '')", 'a/')
+
+ tester("ntpath.join('a/b', 'x/y')", 'a/b\\x/y')
+ tester("ntpath.join('/a/b', 'x/y')", '/a/b\\x/y')
+ tester("ntpath.join('/a/b/', 'x/y')", '/a/b/x/y')
+ tester("ntpath.join('c:', 'x/y')", 'c:x/y')
+ tester("ntpath.join('c:a/b', 'x/y')", 'c:a/b\\x/y')
+ tester("ntpath.join('c:a/b/', 'x/y')", 'c:a/b/x/y')
+ tester("ntpath.join('c:/', 'x/y')", 'c:/x/y')
+ tester("ntpath.join('c:/a/b', 'x/y')", 'c:/a/b\\x/y')
+ tester("ntpath.join('c:/a/b/', 'x/y')", 'c:/a/b/x/y')
+ tester("ntpath.join('//computer/share', 'x/y')", '//computer/share\\x/y')
+ tester("ntpath.join('//computer/share/', 'x/y')", '//computer/share/x/y')
+ tester("ntpath.join('//computer/share/a/b', 'x/y')", '//computer/share/a/b\\x/y')
+
+ tester("ntpath.join('a/b', '/x/y')", '/x/y')
+ tester("ntpath.join('/a/b', '/x/y')", '/x/y')
+ tester("ntpath.join('c:', '/x/y')", 'c:/x/y')
+ tester("ntpath.join('c:a/b', '/x/y')", 'c:/x/y')
+ tester("ntpath.join('c:/', '/x/y')", 'c:/x/y')
+ tester("ntpath.join('c:/a/b', '/x/y')", 'c:/x/y')
+ tester("ntpath.join('//computer/share', '/x/y')", '//computer/share/x/y')
+ tester("ntpath.join('//computer/share/', '/x/y')", '//computer/share/x/y')
+ tester("ntpath.join('//computer/share/a', '/x/y')", '//computer/share/x/y')
+
+ tester("ntpath.join('c:', 'C:x/y')", 'C:x/y')
+ tester("ntpath.join('c:a/b', 'C:x/y')", 'C:a/b\\x/y')
+ tester("ntpath.join('c:/', 'C:x/y')", 'C:/x/y')
+ tester("ntpath.join('c:/a/b', 'C:x/y')", 'C:/a/b\\x/y')
- # from comment in ntpath.join
- tester("ntpath.join('c:', '/a')", 'c:/a')
- tester("ntpath.join('//computer/share', '/a')", '//computer/share/a')
- tester("ntpath.join('c:/', '/a')", 'c:/a')
- tester("ntpath.join('//computer/share/', '/a')", '//computer/share/a')
- tester("ntpath.join('c:/a', '/b')", '/b')
- tester("ntpath.join('//computer/share/a', '/b')", '/b')
- tester("ntpath.join('c:', 'd:/')", 'd:/')
- tester("ntpath.join('c:', '//computer/share/')", '//computer/share/')
- tester("ntpath.join('//computer/share', 'd:/')", 'd:/')
- tester("ntpath.join('//computer/share', '//computer/share/')", '//computer/share/')
- tester("ntpath.join('c:/', 'd:/')", 'd:/')
- tester("ntpath.join('c:/', '//computer/share/')", '//computer/share/')
- tester("ntpath.join('//computer/share/', 'd:/')", 'd:/')
- tester("ntpath.join('//computer/share/', '//computer/share/')", '//computer/share/')
-
- tester("ntpath.join('c:', '//computer/share/')", '//computer/share/')
- tester("ntpath.join('c:/', '//computer/share/')", '//computer/share/')
- tester("ntpath.join('c:/', '//computer/share/a/b')", '//computer/share/a/b')
+ for x in ('', 'a/b', '/a/b', 'c:', 'c:a/b', 'c:/', 'c:/a/b',
+ '//computer/share', '//computer/share/', '//computer/share/a/b'):
+ for y in ('d:', 'd:x/y', 'd:/', 'd:/x/y',
+ '//machine/common', '//machine/common/', '//machine/common/x/y'):
+ tester("ntpath.join(%r, %r)" % (x, y), y)
tester("ntpath.join('\\\\computer\\share\\', 'a', 'b')", '\\\\computer\\share\\a\\b')
tester("ntpath.join('\\\\computer\\share', 'a', 'b')", '\\\\computer\\share\\a\\b')