summaryrefslogtreecommitdiff
path: root/test/backtest.py
diff options
context:
space:
mode:
Diffstat (limited to 'test/backtest.py')
-rw-r--r--test/backtest.py33
1 files changed, 14 insertions, 19 deletions
diff --git a/test/backtest.py b/test/backtest.py
index 21a14d6d..05a1e142 100644
--- a/test/backtest.py
+++ b/test/backtest.py
@@ -4,46 +4,41 @@
# (Redefining built-in blah)
# The whole point of this file is to redefine built-ins, so shut up about it.
-import os, sys
+import os
# Py2k and 3k don't agree on how to run commands in a subprocess.
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.
-
- """
- if sys.hexversion > 0x03000000 and cmd.startswith("coverage "):
- # We don't have a coverage command on 3.x, so fix it up to call the
- # script. Eventually we won't need this.
- cmd = "python " + sys.prefix + os.sep + "Scripts" + os.sep + cmd
+ Returns the exit status code and the combined stdout and stderr.
+
+ """
proc = subprocess.Popen(cmd, shell=True,
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()
if not isinstance(output, str):
output = output.decode('utf-8')
output = output.replace('\r', '')
-
- return retcode, output
+
+ return status, output
# No more execfile in Py3k
try: