Convert other enums to int for Python 2.5 (Stephen Watson).
[rox-lib/lack.git] / tests / python / testrox.py
blobe783b000d699d0cfa0711631d059cab5b057156b
1 #!/usr/bin/env python2.3
2 import unittest
3 import os, sys, shutil
4 from StringIO import StringIO
5 from os.path import dirname, abspath, join
6 rox_lib = dirname(dirname(dirname(abspath(sys.argv[0]))))
7 sys.path.insert(0, join(rox_lib, 'python'))
9 if os.environ.has_key('ROXLIB_TEST_SUB'):
10 import rox
11 for arg in sys.argv[1:]:
12 print arg
13 sys.exit()
14 os.environ['ROXLIB_TEST_SUB'] = 'YES'
16 from rox import processes
18 class TestROX(unittest.TestCase):
19 def try_with_args(self, args):
20 result = StringIO()
21 ptc = processes.PipeThroughCommand(
22 ['./testrox.py'] + args, None, result)
23 ptc.wait()
24 return result.getvalue()
26 def testEmpty(self):
27 self.assertEquals('', self.try_with_args([]))
29 def testStdin(self):
30 self.assertEquals('-\n', self.try_with_args(['-']))
32 def testNormal(self):
33 self.assertEquals('hello\nworld\n',
34 self.try_with_args(['hello', 'world']))
36 def testNormal(self):
37 self.assertEquals('world\n-\n',
38 self.try_with_args(['--g-fatal-warnings',
39 'world', '-']))
41 suite = unittest.makeSuite(TestROX)
42 if __name__ == '__main__':
43 sys.argv.append('-v')
44 unittest.main()