Using doctest and executing a process

Douglas Garstang doug at pobox.com
Mon Mar 11 17:49:55 EST 2002


I'm trying to integrate execution of an external process output into
doctest.

The following snippet of code:

def tester3():
    """
    >>> import os
    >>> os.system ('/bin/ls')
    example.py   example.pyc  tester.py
    0
    """

produces this output:

(dougg at ultra5-4:)%python example.py
example.py   example.pyc  tester.py
*****************************************************************
Failure in example: os.system ('/bin/ls')
from line #2 of example.tester3
Expected:
example.py   example.pyc  tester.py
0
Got: 0
*****************************************************************
1 items had failures:
   1 of   2 in example.tester3
***Test Failed*** 1 failures.

WHY? It runs fine interactively. It also knows to expect the right
stuff. It just SEEMS to think its only getting the return status code
of 0. Where did the other output from the external program go? I also
tried using os.spawnv instead of os.system and I got the same results.

Regards
Douglas Garstang



More information about the Python-list mailing list