diff options
author | Tim Peters <tim.peters@gmail.com> | 2001-07-19 19:11:41 (GMT) |
---|---|---|
committer | Tim Peters <tim.peters@gmail.com> | 2001-07-19 19:11:41 (GMT) |
commit | d4f7f609bfd1ff57f59705b2383305478fb7c411 (patch) | |
tree | bf776b8208e9349d80011166baa642cfede52a3c /Lib/test/test_ntpath.py | |
parent | 3b5e4d1e3cf7b23fcb0bed12763666aa564acaff (diff) | |
download | cpython-d4f7f609bfd1ff57f59705b2383305478fb7c411.zip cpython-d4f7f609bfd1ff57f59705b2383305478fb7c411.tar.gz cpython-d4f7f609bfd1ff57f59705b2383305478fb7c411.tar.bz2 |
Add some test cases for ntpath.join().
Diffstat (limited to 'Lib/test/test_ntpath.py')
-rw-r--r-- | Lib/test/test_ntpath.py | 22 |
1 files changed, 19 insertions, 3 deletions
diff --git a/Lib/test/test_ntpath.py b/Lib/test/test_ntpath.py index b0c1b7c..d1b7a00 100644 --- a/Lib/test/test_ntpath.py +++ b/Lib/test/test_ntpath.py @@ -1,10 +1,11 @@ import ntpath -from test_support import verbose +from test_support import verbose, TestFailed import os errors = 0 def tester(fn, wantResult): + global errors fn = fn.replace("\\", "\\\\") gotResult = eval(fn) if wantResult != gotResult: @@ -13,7 +14,6 @@ def tester(fn, wantResult): print "should be: " + str(wantResult) print " returned: " + str(gotResult) print "" - global errors errors = errors + 1 tester('ntpath.splitdrive("c:\\foo\\bar")', @@ -50,7 +50,23 @@ tester('ntpath.commonprefix(["\\home\\swen\\spam", "\\home\\swen\\eggs"])', tester('ntpath.commonprefix(["/home/swen/spam", "/home/swen/spam"])', "/home/swen/spam") +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:", "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') +tester('ntpath.join("a", "b\\", "c")', 'a\\b\\c') +tester('ntpath.join("a", "b", "\\c")', '\\c') + if errors: - print str(errors) + " errors." + raise TestFailed(str(errors) + " errors.") elif verbose: print "No errors. Thank your lucky stars." |