diff options
author | Ned Batchelder <ned@nedbatchelder.com> | 2010-02-28 13:11:21 -0500 |
---|---|---|
committer | Ned Batchelder <ned@nedbatchelder.com> | 2010-02-28 13:11:21 -0500 |
commit | 99d5e7491a3b73a44de306b9735c26e4d63c0f20 (patch) | |
tree | bb91eacce9be27ffb843231697ed230c5299a53c /test/backtest.py | |
parent | 6dda195647a19a94a88c299ef4521626ebd044e1 (diff) | |
download | python-coveragepy-99d5e7491a3b73a44de306b9735c26e4d63c0f20.tar.gz |
If the user's code calls sys.exit(), honor the request and exit with that status. Fixes issue #50.
Diffstat (limited to 'test/backtest.py')
-rw-r--r-- | test/backtest.py | 14 |
1 files changed, 7 insertions, 7 deletions
diff --git a/test/backtest.py b/test/backtest.py index 4460a78..05a1e14 100644 --- a/test/backtest.py +++ b/test/backtest.py @@ -10,19 +10,19 @@ import os try: import subprocess except ImportError: - def run_command(cmd): + def run_command(cmd, status=0): """Run a command in a subprocess. - Returns the exit code and the combined stdout and stderr. + Returns the exit status code and the combined stdout and stderr. """ _, stdouterr = os.popen4(cmd) - return 0, stdouterr.read() + return status, stdouterr.read() else: - def run_command(cmd): + def run_command(cmd, status=0): """Run a command in a subprocess. - Returns the exit code and the combined stdout and stderr. + Returns the exit status code and the combined stdout and stderr. """ @@ -30,7 +30,7 @@ else: stdin=subprocess.PIPE, stdout=subprocess.PIPE, stderr=subprocess.STDOUT ) - retcode = proc.wait() + status = proc.wait() # Get the output, and canonicalize it to strings with newlines. output = proc.stdout.read() @@ -38,7 +38,7 @@ else: output = output.decode('utf-8') output = output.replace('\r', '') - return retcode, output + return status, output # No more execfile in Py3k try: |