Back to index

radiance  4R0+20100331
test_lam.py
Go to the documentation of this file.
00001 
00002 import os
00003 import math
00004 import string
00005 import unittest
00006 
00007 from unit_tools import support
00008 from unit_tools import lcompare
00009 
00010 class LamTestCase(unittest.TestCase):
00011        def setUp(self):
00012               self.oldpath = os.environ['PATH']
00013               os.environ['PATH'] = os.path.abspath(support.BINDIR)
00014 
00015        def tearDown(self):
00016               os.environ['PATH'] = self.oldpath
00017 
00018        def test_lam(self):
00019               dat_de = support.datafile('lam_de.dat')
00020               dat_en = support.datafile('lam_en.dat')
00021               cmd = 'rlam -t: "%s" "%s"' % (dat_de, dat_en)
00022               raw = os.popen(cmd).read()
00023               result = map(string.split,string.split(raw,'\n'))
00024               expect = [
00025               ['eins:one'],
00026               ['zwei:two'],
00027               ['drei:three'],
00028               ['vier:four'],
00029               ['fuenf:five'],
00030        ]
00031               try: lcompare.llcompare(result, expect, ignore_empty=1)
00032               except lcompare.error, e:
00033                      self.fail('%s [%s]' % (str(e),cmd))
00034 
00035 def main():
00036        support.run_case(LamTestCase)
00037 
00038 if __name__ == '__main__':
00039        main()
00040 
00041 # vi: set ts=4 sw=4 :