struct.pack has become picky about h (short) and H (unsigned short).
[python/dscho.git] / Lib / dos-8x3 / test_ntp.py
blob11f2f44167ca3e12fff191135aca963e4bd661dd
1 import ntpath
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('ntpath.splitdrive("c:\\foo\\bar")', ('c:', '\\foo\\bar'))
20 tester('ntpath.splitunc("\\\\conky\\mountpoint\\foo\\bar")', ('\\\\conky\\mountpoint', '\\foo\\bar'))
21 tester('ntpath.splitdrive("c:/foo/bar")', ('c:', '/foo/bar'))
22 tester('ntpath.splitunc("//conky/mountpoint/foo/bar")', ('//conky/mountpoint', '/foo/bar'))
24 tester('ntpath.split("c:\\foo\\bar")', ('c:\\foo', 'bar'))
25 tester('ntpath.split("\\\\conky\\mountpoint\\foo\\bar")', ('\\\\conky\\mountpoint\\foo', 'bar'))
27 tester('ntpath.split("c:\\")', ('c:\\', ''))
28 tester('ntpath.split("\\\\conky\\mountpoint\\")', ('\\\\conky\\mountpoint', ''))
30 tester('ntpath.split("c:/")', ('c:/', ''))
31 tester('ntpath.split("//conky/mountpoint/")', ('//conky/mountpoint', ''))
33 tester('ntpath.isabs("c:\\")', 1)
34 tester('ntpath.isabs("\\\\conky\\mountpoint\\")', 1)
35 tester('ntpath.isabs("\\foo")', 1)
36 tester('ntpath.isabs("\\foo\\bar")', 1)
38 tester('ntpath.abspath("C:\\")', "C:\\")
40 tester('ntpath.commonprefix(["/home/swenson/spam", "/home/swen/spam"])',
41 "/home/swen")
42 tester('ntpath.commonprefix(["\\home\\swen\\spam", "\\home\\swen\\eggs"])',
43 "\\home\\swen\\")
44 tester('ntpath.commonprefix(["/home/swen/spam", "/home/swen/spam"])',
45 "/home/swen/spam")
47 if errors:
48 print str(errors) + " errors."
49 else:
50 print "No errors. Thank your lucky stars."