summaryrefslogtreecommitdiff
path: root/test/backtest.py
diff options
context:
space:
mode:
Diffstat (limited to 'test/backtest.py')
-rw-r--r--test/backtest.py22
1 files changed, 8 insertions, 14 deletions
diff --git a/test/backtest.py b/test/backtest.py
index 58b16474..05a1e142 100644
--- a/test/backtest.py
+++ b/test/backtest.py
@@ -4,39 +4,33 @@
# (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.
+ Returns the exit status 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.
- script_path = os.path.join(sys.prefix, "Scripts", cmd)
- cmd = "python " + script_path
-
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()
@@ -44,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: