summaryrefslogtreecommitdiff
path: root/tests/helpers.py
diff options
context:
space:
mode:
authorNed Batchelder <ned@nedbatchelder.com>2015-10-25 17:40:09 -0400
committerNed Batchelder <ned@nedbatchelder.com>2015-10-25 17:40:09 -0400
commitb810cbc0d06df0a04e3380166215b8ad2f40524c (patch)
treeb0ea1499815b84301fa7991e37de128265526e81 /tests/helpers.py
parent15100248c12b85a00278371fea60f07718a9d499 (diff)
downloadpython-coveragepy-git-b810cbc0d06df0a04e3380166215b8ad2f40524c.tar.gz
Properly handle filenames with non-ASCII characters. #432
Diffstat (limited to 'tests/helpers.py')
-rw-r--r--tests/helpers.py7
1 files changed, 6 insertions, 1 deletions
diff --git a/tests/helpers.py b/tests/helpers.py
index aa094bc1..2723ea59 100644
--- a/tests/helpers.py
+++ b/tests/helpers.py
@@ -4,6 +4,7 @@
"""Helpers for coverage.py tests."""
import subprocess
+import sys
def run_command(cmd):
@@ -12,8 +13,12 @@ def run_command(cmd):
Returns the exit status code and the combined stdout and stderr.
"""
+ # In some strange cases (PyPy3 in a virtualenv!?) the stdout encoding of
+ # the subprocess is set incorrectly to ascii. Use an environment variable
+ # to force the encoding to be the same as ours.
proc = subprocess.Popen(
- cmd, shell=True,
+ "PYTHONIOENCODING=%s %s" % (sys.__stdout__.encoding, cmd),
+ shell=True,
stdin=subprocess.PIPE, stdout=subprocess.PIPE,
stderr=subprocess.STDOUT
)