summaryrefslogtreecommitdiffstats
path: root/Lib/test/test_ntpath.py
diff options
context:
space:
mode:
authorSerhiy Storchaka <storchaka@gmail.com>2014-01-27 21:16:28 (GMT)
committerSerhiy Storchaka <storchaka@gmail.com>2014-01-27 21:16:28 (GMT)
commitf5d2f22475a340d65bf631f7bb0e5219a16ecae0 (patch)
tree933e0bf5874045610fb3b16bd2ae8c17d6701665 /Lib/test/test_ntpath.py
parent2393dca4721b308704f3bc8c8791b06062daa7e3 (diff)
parentc369c2c688c407433d88a7cad75cda88fbe799b5 (diff)
downloadcpython-f5d2f22475a340d65bf631f7bb0e5219a16ecae0.zip
cpython-f5d2f22475a340d65bf631f7bb0e5219a16ecae0.tar.gz
cpython-f5d2f22475a340d65bf631f7bb0e5219a16ecae0.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.py69
1 files changed, 36 insertions, 33 deletions
diff --git a/Lib/test/test_ntpath.py b/Lib/test/test_ntpath.py
index 2e6ba63..e789e22 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\\')
-
- # 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')
+ 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')
+
+ 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')