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