ViewVC Help
View File | Revision Log | Show Annotations | Download File | Root Listing
root/radiance/ray/test/py_tests/test_ttyimage.py
Revision: 1.4
Committed: Mon Mar 28 17:48:43 2016 UTC (9 years, 1 month ago) by schorsch
Content type: text/x-python
Branch: MAIN
CVS Tags: HEAD
Changes since 1.3: +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

# User Rev Content
1 schorsch 1.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 schorsch 1.3 _bindir = None
12    
13 schorsch 1.1 class TtyimageTestCase(unittest.TestCase):
14     def setUp(self):
15 schorsch 1.3 if _bindir:
16     self.oldpath = os.environ['PATH']
17     os.environ['PATH'] = _bindir
18 schorsch 1.1
19     def tearDown(self):
20 schorsch 1.3 if _bindir:
21     os.environ['PATH'] = self.oldpath
22 schorsch 1.1
23     def test_ttyimage(self):
24 schorsch 1.2 '''We just do a few spot checks here'''
25 schorsch 1.1 picfile = support.datafile('Earth128.pic')
26     cmd = 'ttyimage "%s"' % picfile
27     res0 = os.popen(cmd).read()
28     result = map(string.split,string.split(res0, '\n'))
29     expect = [[0,
30     ['################################################################'
31     '################################################################']],
32     [7,
33     ['#########################@%,,.?++&%%###$&###############@&:.....'
34     '.......,,.......,,.,,;..+?,...,.:*+.:&#########@################']],
35     [23,
36     ['.......;,:.....,++*+?++++;+;:,::,..,,;+;;+...................,;,'
37     '..,:;+::+;;:;;:;;;;;:;+;;;;;;;;;:;+;;;;;%%$@%$&%#?.....,#%......']],
38     [54,
39     ['................................,,,.......................*%?$@#'
40     '###########@$%%%;.........:?:.....,?+;:....;,...................']],
41     [99,
42     ['.....................................+++........................'
43     '................................................................']],
44     ]
45    
46     for l in expect:
47     self.assertEqual(result[l[0]], l[1],
48     '%s : %s != %s [line %s]' % (cmd,result[l[0]],l[1], l[0]))
49    
50 schorsch 1.3 def main(bindir=None):
51     global _bindir
52     _bindir=bindir
53 schorsch 1.1 support.run_case(TtyimageTestCase)
54    
55     if __name__ == '__main__':
56     main()
57    
58     # vi: set ts=4 sw=4 :