blob: 11f2f44167ca3e12fff191135aca963e4bd661dd [file] [log] [blame]
Guido van Rossum2e7840f1999-02-09 18:40:13 +00001import ntpath
2import string
Guido van Rossum8d691c82000-09-01 19:25:51 +00003import os
Guido van Rossum2e7840f1999-02-09 18:40:13 +00004
5errors = 0
6
7def tester(fn, wantResult):
8 fn = string.replace(fn, "\\", "\\\\")
9 gotResult = eval(fn)
10 if wantResult != gotResult:
11 print "error!"
12 print "evaluated: " + str(fn)
13 print "should be: " + str(wantResult)
14 print " returned: " + str(gotResult)
15 print ""
16 global errors
17 errors = errors + 1
18
19tester('ntpath.splitdrive("c:\\foo\\bar")', ('c:', '\\foo\\bar'))
Guido van Rossum9a744a91999-04-08 20:27:54 +000020tester('ntpath.splitunc("\\\\conky\\mountpoint\\foo\\bar")', ('\\\\conky\\mountpoint', '\\foo\\bar'))
Guido van Rossum2e7840f1999-02-09 18:40:13 +000021tester('ntpath.splitdrive("c:/foo/bar")', ('c:', '/foo/bar'))
Guido van Rossum9a744a91999-04-08 20:27:54 +000022tester('ntpath.splitunc("//conky/mountpoint/foo/bar")', ('//conky/mountpoint', '/foo/bar'))
Guido van Rossum2e7840f1999-02-09 18:40:13 +000023
24tester('ntpath.split("c:\\foo\\bar")', ('c:\\foo', 'bar'))
25tester('ntpath.split("\\\\conky\\mountpoint\\foo\\bar")', ('\\\\conky\\mountpoint\\foo', 'bar'))
26
27tester('ntpath.split("c:\\")', ('c:\\', ''))
Guido van Rossum9a744a91999-04-08 20:27:54 +000028tester('ntpath.split("\\\\conky\\mountpoint\\")', ('\\\\conky\\mountpoint', ''))
Guido van Rossum2e7840f1999-02-09 18:40:13 +000029
30tester('ntpath.split("c:/")', ('c:/', ''))
Guido van Rossum9a744a91999-04-08 20:27:54 +000031tester('ntpath.split("//conky/mountpoint/")', ('//conky/mountpoint', ''))
Guido van Rossum2e7840f1999-02-09 18:40:13 +000032
33tester('ntpath.isabs("c:\\")', 1)
34tester('ntpath.isabs("\\\\conky\\mountpoint\\")', 1)
35tester('ntpath.isabs("\\foo")', 1)
36tester('ntpath.isabs("\\foo\\bar")', 1)
37
Guido van Rossum8d691c82000-09-01 19:25:51 +000038tester('ntpath.abspath("C:\\")', "C:\\")
39
40tester('ntpath.commonprefix(["/home/swenson/spam", "/home/swen/spam"])',
41 "/home/swen")
42tester('ntpath.commonprefix(["\\home\\swen\\spam", "\\home\\swen\\eggs"])',
43 "\\home\\swen\\")
44tester('ntpath.commonprefix(["/home/swen/spam", "/home/swen/spam"])',
45 "/home/swen/spam")
46
Guido van Rossum2e7840f1999-02-09 18:40:13 +000047if errors:
48 print str(errors) + " errors."
49else:
50 print "No errors. Thank your lucky stars."
51