Back to index

radiance  4R0+20100331
test_getinfo.py
Go to the documentation of this file.
00001 
00002 
00003 import os
00004 import math
00005 import string
00006 import unittest
00007 
00008 from unit_tools import support
00009 from unit_tools import lcompare
00010 
00011 class GetinfoTestCase(unittest.TestCase):
00012        def setUp(self):
00013               self.oldpath = os.environ['PATH']
00014               os.environ['PATH'] = os.path.abspath(support.BINDIR)
00015 
00016        def tearDown(self):
00017               os.environ['PATH'] = self.oldpath
00018 
00019 
00020        def test_getinfo(self):
00021               picfile = support.datafile('Earth128.pic')
00022               cmd = 'getinfo "%s"' % picfile
00023               res0 = os.popen(cmd).read()
00024               result = lcompare.split_headers(res0)
00025               exps = '''%s:
00026         Xim format conversion by:
00027         FORMAT=32-bit_rle_rgbe
00028         pfilt -e 2 -x 512 -y 512 -p 1 -r .67
00029         EXPOSURE=4.926198e+00
00030         normpat
00031         pfilt -1 -e .2
00032         EXPOSURE=2.000000e-01
00033         pfilt -x 128 -y 128
00034         PIXASPECT=0.500000
00035         EXPOSURE=2.571646e+00''' % picfile
00036               expect = lcompare.split_headers(exps)
00037               try: lcompare.llcompare(result, expect, ignore_empty=1)
00038               except lcompare.error, e:
00039                      self.fail('%s [%s]' % (str(e),cmd))
00040 
00041        def test_getinfo_d(self):
00042               picfile = support.datafile('Earth128.pic')
00043               cmd = 'getinfo -d "%s"' % picfile
00044               res0 = os.popen(cmd).read()
00045               result = map(string.split,string.split(res0, '\n'))
00046               exps = '''%s: -Y 128 +X 128''' % picfile
00047               expect = map(string.split, string.split(exps, '\n'))
00048               try: lcompare.llcompare(result, expect, ignore_empty=1)
00049               except lcompare.error, e:
00050                      self.fail('%s [%s]' % (str(e),cmd))
00051 
00052 def main():
00053        support.run_case(GetinfoTestCase)
00054 
00055 if __name__ == '__main__':
00056        main()
00057 
00058 # vi: set ts=4 sw=4 :