Suppress another deprecation warning in the tests.
[python.git] / Lib / test / test_rgbimg.py
blob650c02aa0f9a6adc32080ee88b3448a5908c6524
1 # Testing rgbimg module
3 import warnings
4 warnings.filterwarnings("ignore",
5 "the rgbimg module is deprecated",
6 DeprecationWarning,
7 ".*test_rgbimg$")
8 import rgbimg
10 import os, uu
12 from test.test_support import verbose, unlink, findfile
14 class error(Exception):
15 pass
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()
27 if rgb != raw:
28 raise error, \
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')
32 os.unlink('@.rgb')
34 table = [
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)
42 if verbose:
43 print "uudecoding", source, "->", target, "..."
44 uu.decode(source, target)
46 if verbose:
47 print "testing..."
49 ttob = rgbimg.ttob(0)
50 if ttob != 0:
51 raise error, 'ttob should start out as zero'
53 testimg('test'+os.extsep+'rgb', 'test'+os.extsep+'rawimg')
55 ttob = rgbimg.ttob(1)
56 if ttob != 0:
57 raise error, 'ttob should be zero'
59 testimg('test'+os.extsep+'rgb', 'test'+os.extsep+'rawimg'+os.extsep+'rev')
61 ttob = rgbimg.ttob(0)
62 if ttob != 1:
63 raise error, 'ttob should be one'
65 ttob = rgbimg.ttob(0)
66 if ttob != 0:
67 raise error, 'ttob should be zero'
69 for source, target in table:
70 unlink(findfile(target))