Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit ead9d8d

Browse files
committed
New test for ntpath module
1 parent 534972b commit ead9d8d

2 files changed

Lines changed: 43 additions & 0 deletions

File tree

Lib/test/output/test_ntpath

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
test_ntpath
2+
No errors. Thank your lucky stars.

Lib/test/test_ntpath.py

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
import ntpath
2+
import string
3+
4+
errors = 0
5+
6+
def tester(fn, wantResult):
7+
fn = string.replace(fn, "\\", "\\\\")
8+
gotResult = eval(fn)
9+
if wantResult != gotResult:
10+
print "error!"
11+
print "evaluated: " + str(fn)
12+
print "should be: " + str(wantResult)
13+
print " returned: " + str(gotResult)
14+
print ""
15+
global errors
16+
errors = errors + 1
17+
18+
tester('ntpath.splitdrive("c:\\foo\\bar")', ('c:', '\\foo\\bar'))
19+
tester('ntpath.splitdrive("\\\\conky\\mountpoint\\foo\\bar")', ('\\\\conky\\mountpoint', '\\foo\\bar'))
20+
tester('ntpath.splitdrive("c:/foo/bar")', ('c:', '/foo/bar'))
21+
tester('ntpath.splitdrive("//conky/mountpoint/foo/bar")', ('//conky/mountpoint', '/foo/bar'))
22+
23+
tester('ntpath.split("c:\\foo\\bar")', ('c:\\foo', 'bar'))
24+
tester('ntpath.split("\\\\conky\\mountpoint\\foo\\bar")', ('\\\\conky\\mountpoint\\foo', 'bar'))
25+
26+
tester('ntpath.split("c:\\")', ('c:\\', ''))
27+
tester('ntpath.split("\\\\conky\\mountpoint\\")', ('\\\\conky\\mountpoint\\', ''))
28+
29+
tester('ntpath.split("c:/")', ('c:/', ''))
30+
tester('ntpath.split("//conky/mountpoint/")', ('//conky/mountpoint/', ''))
31+
32+
tester('ntpath.isabs("c:\\")', 1)
33+
tester('ntpath.isabs("\\\\conky\\mountpoint\\")', 1)
34+
tester('ntpath.isabs("\\foo")', 1)
35+
tester('ntpath.isabs("\\foo\\bar")', 1)
36+
37+
if errors:
38+
print str(errors) + " errors."
39+
else:
40+
print "No errors. Thank your lucky stars."
41+

0 commit comments

Comments
 (0)