summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--tests/helpers.py7
1 files changed, 6 insertions, 1 deletions
diff --git a/tests/helpers.py b/tests/helpers.py
index d652fe8e..be2484f3 100644
--- a/tests/helpers.py
+++ b/tests/helpers.py
@@ -22,10 +22,15 @@ def run_command(cmd):
# 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.
+ sub_env = dict(os.environ)
+ encoding = sys.__stdout__.encoding
+ if encoding:
+ sub_env['PYTHONIOENCODING'] = encoding
+
proc = subprocess.Popen(
cmd,
shell=True,
- env=dict(os.environ, PYTHONIOENCODING=sys.__stdout__.encoding),
+ env=sub_env,
stdin=subprocess.PIPE, stdout=subprocess.PIPE,
stderr=subprocess.STDOUT
)