#!/www/python/bin/python

"""$URL: svn+ssh://svn.mems-exchange.org/repos/trunk/dulcinea/lib/test/test_child_process.py $
$Id: test_child_process.py 20909 2003-03-04 14:35:33Z dbinger $

Test for dulcinea.child_process.
"""

from sancho.unittest import TestScenario, parse_args, run_scenarios
from dulcinea import child_process

tested_modules = ["dulcinea.child_process" ]

class ChildProcessTest (TestScenario):

    def check_cat (self):
        p = child_process.execute(('cat',))
        self.test_stmt('p.write("hello world\\n")')
        self.test_stmt('p.stdin.close()')
        self.test_val('p.readline()', 'hello world\n')
        self.test_val('p.close()', None)

    def check_ls (self):
        p = child_process.execute(("ls", "/"))
        self.test_val('p.readline()', 'bin\n')
        self.test_val('p.readline()', 'boot\n')
        self.test_val('p.close()', None)

    def check_error (self):
        p = child_process.execute(("false",))
        self.test_val('p.close()', 256)


if __name__ == "__main__":
    (scenarios, options) = parse_args()
    run_scenarios(scenarios, options)
