ViewVC Help
View File | Revision Log | Show Annotations | Download File | Root Listing
root/radiance/ray/test/py_tests/test_cnt.py
Revision: 1.3
Committed: Mon Mar 28 17:48:43 2016 UTC (8 years, 1 month ago) by schorsch
Content type: text/x-python
Branch: MAIN
CVS Tags: HEAD
Changes since 1.2: +0 -0 lines
State: FILE REMOVED
Log Message:
Refactoring of test suite, use independently of SCons and with Py2.7 or 3.x.

File Contents

# Content
1
2
3 import os
4 import math
5 import string
6 import unittest
7
8 from unit_tools import support
9 from unit_tools import lcompare
10
11 _bindir = None
12
13 class CntTestCase(unittest.TestCase):
14 def setUp(self):
15 if _bindir:
16 self.oldpath = os.environ['PATH']
17 os.environ['PATH'] = _bindir
18
19 def tearDown(self):
20 if _bindir:
21 os.environ['PATH'] = self.oldpath
22
23 def test_1(self):
24 cmd = 'cnt 5'
25 res0 = os.popen(cmd).read()
26 res = map(string.strip,string.split(res0, '\n'))
27 exp = [0, 1, 2, 3, 4, '']
28 try: lcompare.lcompare(res, exp)
29 except lcompare.error, e: self.fail(str(e))
30
31 def test_2(self):
32 cmd = 'cnt 3 2'
33 res0 = os.popen(cmd).read()
34 res = map(string.split,string.split(res0, '\n'))
35 exp = [[0,0], [0,1], [1,0], [1,1], [2,0], [2,1], []]
36 try: lcompare.llcompare(res, exp)
37 except lcompare.error, e: self.fail(str(e))
38
39 def test_3(self):
40 cmd = 'cnt 3 2 3'
41 res0 = os.popen(cmd).read()
42 res = map(string.split,string.split(res0, '\n'))
43 exp = [[0,0,0],[0,0,1],[0,0,2],
44 [0,1,0],[0,1,1],[0,1,2],
45 [1,0,0],[1,0,1],[1,0,2],
46 [1,1,0],[1,1,1],[1,1,2],
47 [2,0,0],[2,0,1],[2,0,2],
48 [2,1,0],[2,1,1],[2,1,2],
49 []]
50 try: lcompare.llcompare(res, exp)
51 except lcompare.error, e: self.fail(str(e))
52
53
54 def main(bindir=None):
55 global _bindir
56 _bindir=bindir
57 support.run_case(CntTestCase)
58
59 if __name__ == '__main__':
60 main()
61
62 # vi: set ts=4 sw=4 :