Back to index

radiance  4R0+20100331
test_genbeads.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 GenbeadsTestCase(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_genbeads(self):
00019               cmd = 'genbeads mymat myname 0 0 0 1 1 1 2 0 0 0 2 0 .1 .4'
00020               raw = os.popen(cmd).read()
00021               result = map(string.split,string.split(raw,'\n'))
00022               expect = [['mymat', 'sphere', 'myname.0'], [0], [0],
00023               [4, 0, 0, 0, 0.1],
00024               ['mymat', 'sphere', 'myname.1'], [0], [0],
00025               [4, 0.36, 0.04, 0.104, 0.1],
00026               ['mymat', 'sphere', 'myname.2'], [0], [0],
00027               [4, 0.651440715413, 0.167781092737, 0.365893348046, 0.1],
00028               ['mymat', 'sphere', 'myname.3'], [0], [0],
00029               [4, 0.844350245496, 0.366600314978, 0.655866088042, 0.1],
00030               ['mymat', 'sphere', 'myname.4'], [0], [0],
00031               [4, 0.960791445178, 0.643185551339, 0.897901825177, 0.1],
00032               ]
00033               try: lcompare.llcompare(result, expect, ignore_empty=1)
00034               except lcompare.error, e:
00035                      self.fail('%s [%s]' % (str(e),cmd))
00036 
00037 
00038 def main():
00039        support.run_case(GenbeadsTestCase)
00040 
00041 if __name__ == '__main__':
00042        main()
00043 
00044 # vi: set ts=4 sw=4 :