ViewVC Help
View File | Revision Log | Show Annotations | Download File | Root Listing
root/radiance/ray/test/testcases/px/test_ttyimage.py
Revision: 1.1
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: rad5R4, rad5R2, rad5R3, HEAD
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 # -*- coding: utf-8 -*-
2     from __future__ import division, print_function, unicode_literals
3    
4     import unittest
5    
6     import testsupport as ts
7     from pyradlib import lcompare
8     from pyradlib.pyrad_proc import PIPE, Error, ProcMixin
9    
10    
11     class TtyimageTestCase(unittest.TestCase, ProcMixin):
12    
13     def _runit(self, cmd):
14     try:
15     proc = self.call_one(cmd, 'call ttyimage', out=PIPE,
16     universal_newlines=True)
17     raw = proc.stdout.read()
18     except Error as e:
19     self.fail('%s [%s]' % (str(e), self.qjoin(cmd)))
20     finally:
21     proc.wait()
22     return [s.split() for s in raw.split('\n')]
23    
24     def test_ttyimage(self):
25     # We just do a few spot checks here
26     picfile = ts.datafile('Earth128.pic')
27     cmd = ['ttyimage', picfile]
28     result = self._runit(cmd)
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    
51     # vi: set ts=4 sw=4 :