1 # Testing rgbimg module
4 warnings
.filterwarnings("ignore",
5 "the rgbimg module is deprecated",
12 from test
.test_support
import verbose
, unlink
, findfile
14 class error(Exception):
17 print 'RGBimg test suite:'
19 def testimg(rgb_file
, raw_file
):
20 rgb_file
= findfile(rgb_file
)
21 raw_file
= findfile(raw_file
)
22 width
, height
= rgbimg
.sizeofimage(rgb_file
)
23 rgb
= rgbimg
.longimagedata(rgb_file
)
24 if len(rgb
) != width
* height
* 4:
25 raise error
, 'bad image length'
26 raw
= open(raw_file
, 'rb').read()
29 'images don\'t match for '+rgb_file
+' and '+raw_file
30 for depth
in [1, 3, 4]:
31 rgbimg
.longstoimage(rgb
, width
, height
, depth
, '@.rgb')
35 ('testrgb'+os
.extsep
+'uue', 'test'+os
.extsep
+'rgb'),
36 ('testimg'+os
.extsep
+'uue', 'test'+os
.extsep
+'rawimg'),
37 ('testimgr'+os
.extsep
+'uue', 'test'+os
.extsep
+'rawimg'+os
.extsep
+'rev'),
39 for source
, target
in table
:
40 source
= findfile(source
)
41 target
= findfile(target
)
43 print "uudecoding", source
, "->", target
, "..."
44 uu
.decode(source
, target
)
51 raise error
, 'ttob should start out as zero'
53 testimg('test'+os
.extsep
+'rgb', 'test'+os
.extsep
+'rawimg')
57 raise error
, 'ttob should be zero'
59 testimg('test'+os
.extsep
+'rgb', 'test'+os
.extsep
+'rawimg'+os
.extsep
+'rev')
63 raise error
, 'ttob should be one'
67 raise error
, 'ttob should be zero'
69 for source
, target
in table
:
70 unlink(findfile(target
))