blob: ffa3ef7237100f6e690162589774eb9260093bab [file] [log] [blame]
Skip Montanaro640f4832000-08-23 16:55:00 +00001import dospath
2import string
3import os
4
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('dospath.splitdrive("c:\\foo\\bar")', ('c:', '\\foo\\bar'))
20tester('dospath.splitdrive("c:/foo/bar")', ('c:', '/foo/bar'))
21
22tester('dospath.split("c:\\foo\\bar")', ('c:\\foo', 'bar'))
23tester('dospath.split("\\\\conky\\mountpoint\\foo\\bar")', ('\\\\conky\\mountpoint\\foo', 'bar'))
24
25tester('dospath.split("c:\\")', ('c:\\', ''))
26tester('dospath.split("\\\\conky\\mountpoint\\")', ('\\\\conky\\mountpoint', ''))
27
28tester('dospath.split("c:/")', ('c:/', ''))
29tester('dospath.split("//conky/mountpoint/")', ('//conky/mountpoint', ''))
30
31tester('dospath.isabs("c:\\")', 1)
32tester('dospath.isabs("\\\\conky\\mountpoint\\")', 1)
33tester('dospath.isabs("\\foo")', 1)
34tester('dospath.isabs("\\foo\\bar")', 1)
35
36tester('dospath.abspath("C:\\")', "C:\\")
37
38tester('dospath.commonprefix(["/home/swenson/spam", "/home/swen/spam"])',
39 "/home/swen")
40tester('dospath.commonprefix(["\\home\\swen\\spam", "\\home\\swen\\eggs"])',
41 "\\home\\swen\\")
42tester('dospath.commonprefix(["/home/swen/spam", "/home/swen/spam"])',
43 "/home/swen/spam")
44
45if errors:
46 print str(errors) + " errors."
47else:
48 print "No errors. Thank your lucky stars."
49