blob: 9c79865afaf311f4c30811ae5198b2b512d1defe [file] [log] [blame]
Guido van Rossumead9d8d1999-02-03 17:21:21 +00001import ntpath
2import string
3
4errors = 0
5
6def 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
18tester('ntpath.splitdrive("c:\\foo\\bar")', ('c:', '\\foo\\bar'))
19tester('ntpath.splitdrive("\\\\conky\\mountpoint\\foo\\bar")', ('\\\\conky\\mountpoint', '\\foo\\bar'))
20tester('ntpath.splitdrive("c:/foo/bar")', ('c:', '/foo/bar'))
21tester('ntpath.splitdrive("//conky/mountpoint/foo/bar")', ('//conky/mountpoint', '/foo/bar'))
22
23tester('ntpath.split("c:\\foo\\bar")', ('c:\\foo', 'bar'))
24tester('ntpath.split("\\\\conky\\mountpoint\\foo\\bar")', ('\\\\conky\\mountpoint\\foo', 'bar'))
25
26tester('ntpath.split("c:\\")', ('c:\\', ''))
27tester('ntpath.split("\\\\conky\\mountpoint\\")', ('\\\\conky\\mountpoint\\', ''))
28
29tester('ntpath.split("c:/")', ('c:/', ''))
30tester('ntpath.split("//conky/mountpoint/")', ('//conky/mountpoint/', ''))
31
32tester('ntpath.isabs("c:\\")', 1)
33tester('ntpath.isabs("\\\\conky\\mountpoint\\")', 1)
34tester('ntpath.isabs("\\foo")', 1)
35tester('ntpath.isabs("\\foo\\bar")', 1)
36
37if errors:
38 print str(errors) + " errors."
39else:
40 print "No errors. Thank your lucky stars."
41