summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNed Batchelder <ned@nedbatchelder.com>2015-10-25 19:51:41 -0400
committerNed Batchelder <ned@nedbatchelder.com>2015-10-25 19:51:41 -0400
commit7c178919e8a8ef9104bf415c5529c63db707abb6 (patch)
treee32f6f21180d65fbddbea2dfd2470441e6e510ce
parentd2f814d4e90601ee40d6528281f74d9037002f42 (diff)
downloadpython-coveragepy-7c178919e8a8ef9104bf415c5529c63db707abb6.tar.gz
Account for no encoding at all...
-rw-r--r--tests/helpers.py8
1 files changed, 5 insertions, 3 deletions
diff --git a/tests/helpers.py b/tests/helpers.py
index 67d51b2..fa94b10 100644
--- a/tests/helpers.py
+++ b/tests/helpers.py
@@ -17,9 +17,11 @@ 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, PYTHONIOENCODING=sys.__stdout__.encoding)
- print("__stdout__: %r, enc = %r" % (sys.__stdout__, sys.__stdout__.encoding))
- print("stdout: %r, enc = %r" % (sys.stdout, sys.stdout.encoding))
+ sub_env = dict(os.environ)
+ encoding = sys.__stdout__.encoding
+ if encoding:
+ sub_env['PYTHONIOENCODING'] = encoding
+
proc = subprocess.Popen(
cmd,
shell=True,