1 # Testing rgbimg module
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()
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')
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
)
35 print "uudecoding", source
, "->", target
, "..."
36 uu
.decode(source
, target
)
43 raise error
, 'ttob should start out as zero'
45 testimg('test.rgb', 'test.rawimg')
49 raise error
, 'ttob should be zero'
51 testimg('test.rgb', 'test.rawimg.rev')
55 raise error
, 'ttob should be one'
59 raise error
, 'ttob should be zero'
61 for source
, target
in table
:
62 unlink(findfile(target
))