struct.pack has become picky about h (short) and H (unsigned short).
[python/dscho.git] / Lib / dos-8x3 / test_dos.py
blobffa3ef7237100f6e690162589774eb9260093bab
1 import dospath
2 import string
3 import os
5 errors = 0
7 def 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
19 tester('dospath.splitdrive("c:\\foo\\bar")', ('c:', '\\foo\\bar'))
20 tester('dospath.splitdrive("c:/foo/bar")', ('c:', '/foo/bar'))
22 tester('dospath.split("c:\\foo\\bar")', ('c:\\foo', 'bar'))
23 tester('dospath.split("\\\\conky\\mountpoint\\foo\\bar")', ('\\\\conky\\mountpoint\\foo', 'bar'))
25 tester('dospath.split("c:\\")', ('c:\\', ''))
26 tester('dospath.split("\\\\conky\\mountpoint\\")', ('\\\\conky\\mountpoint', ''))
28 tester('dospath.split("c:/")', ('c:/', ''))
29 tester('dospath.split("//conky/mountpoint/")', ('//conky/mountpoint', ''))
31 tester('dospath.isabs("c:\\")', 1)
32 tester('dospath.isabs("\\\\conky\\mountpoint\\")', 1)
33 tester('dospath.isabs("\\foo")', 1)
34 tester('dospath.isabs("\\foo\\bar")', 1)
36 tester('dospath.abspath("C:\\")', "C:\\")
38 tester('dospath.commonprefix(["/home/swenson/spam", "/home/swen/spam"])',
39 "/home/swen")
40 tester('dospath.commonprefix(["\\home\\swen\\spam", "\\home\\swen\\eggs"])',
41 "\\home\\swen\\")
42 tester('dospath.commonprefix(["/home/swen/spam", "/home/swen/spam"])',
43 "/home/swen/spam")
45 if errors:
46 print str(errors) + " errors."
47 else:
48 print "No errors. Thank your lucky stars."