| 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 TtyimageTestCase(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_ttyimage(self): |
| 24 |
'''We just do a few spot checks here''' |
| 25 |
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 |
def main(bindir=None): |
| 51 |
global _bindir |
| 52 |
_bindir=bindir |
| 53 |
support.run_case(TtyimageTestCase) |
| 54 |
|
| 55 |
if __name__ == '__main__': |
| 56 |
main() |
| 57 |
|
| 58 |
# vi: set ts=4 sw=4 : |