1 # Testing rgbimg module
5 from test
.test_support
import verbose
, unlink
, findfile
7 class error(Exception):
10 print 'RGBimg test suite:'
12 def testimg(rgb_file
, raw_file
):
13 rgb_file
= findfile(rgb_file
)
14 raw_file
= findfile(raw_file
)
15 width
, height
= rgbimg
.sizeofimage(rgb_file
)
16 rgb
= rgbimg
.longimagedata(rgb_file
)
17 if len(rgb
) != width
* height
* 4:
18 raise error
, 'bad image length'
19 raw
= open(raw_file
, 'rb').read()
22 'images don\'t match for '+rgb_file
+' and '+raw_file
23 for depth
in [1, 3, 4]:
24 rgbimg
.longstoimage(rgb
, width
, height
, depth
, '@.rgb')
28 ('testrgb'+os
.extsep
+'uue', 'test'+os
.extsep
+'rgb'),
29 ('testimg'+os
.extsep
+'uue', 'test'+os
.extsep
+'rawimg'),
30 ('testimgr'+os
.extsep
+'uue', 'test'+os
.extsep
+'rawimg'+os
.extsep
+'rev'),
32 for source
, target
in table
:
33 source
= findfile(source
)
34 target
= findfile(target
)
36 print "uudecoding", source
, "->", target
, "..."
37 uu
.decode(source
, target
)
44 raise error
, 'ttob should start out as zero'
46 testimg('test'+os
.extsep
+'rgb', 'test'+os
.extsep
+'rawimg')
50 raise error
, 'ttob should be zero'
52 testimg('test'+os
.extsep
+'rgb', 'test'+os
.extsep
+'rawimg'+os
.extsep
+'rev')
56 raise error
, 'ttob should be one'
60 raise error
, 'ttob should be zero'
62 for source
, target
in table
:
63 unlink(findfile(target
))