Fix an amazing number of typos & malformed sentences reported by Detlef
[python/dscho.git] / Lib / dos-8x3 / test_rgb.py
blob38bcdf565230b87b2e78593852209fe8f8ec0c50
1 # Testing rgbimg module
3 import rgbimg, os, uu
5 from test_support import verbose, unlink, findfile
7 error = 'test_rgbimg.error'
9 print 'RGBimg test suite:'
11 def testimg(rgb_file, raw_file):
12 rgb_file = findfile(rgb_file)
13 raw_file = findfile(raw_file)
14 width, height = rgbimg.sizeofimage(rgb_file)
15 rgb = rgbimg.longimagedata(rgb_file)
16 if len(rgb) != width * height * 4:
17 raise error, 'bad image length'
18 raw = open(raw_file, 'rb').read()
19 if rgb != raw:
20 raise error, \
21 'images don\'t match for '+rgb_file+' and '+raw_file
22 for depth in [1, 3, 4]:
23 rgbimg.longstoimage(rgb, width, height, depth, '@.rgb')
24 os.unlink('@.rgb')
26 table = [
27 ('testrgb.uue', 'test.rgb'),
28 ('testimg.uue', 'test.rawimg'),
29 ('testimgr.uue', 'test.rawimg.rev'),
31 for source, target in table:
32 source = findfile(source)
33 target = findfile(target)
34 if verbose:
35 print "uudecoding", source, "->", target, "..."
36 uu.decode(source, target)
38 if verbose:
39 print "testing..."
41 ttob = rgbimg.ttob(0)
42 if ttob != 0:
43 raise error, 'ttob should start out as zero'
45 testimg('test.rgb', 'test.rawimg')
47 ttob = rgbimg.ttob(1)
48 if ttob != 0:
49 raise error, 'ttob should be zero'
51 testimg('test.rgb', 'test.rawimg.rev')
53 ttob = rgbimg.ttob(0)
54 if ttob != 1:
55 raise error, 'ttob should be one'
57 ttob = rgbimg.ttob(0)
58 if ttob != 0:
59 raise error, 'ttob should be zero'
61 for source, target in table:
62 unlink(findfile(target))