From: Reuben Thomas Date: Mon, 29 Jan 2018 13:51:16 +0000 (+0000) Subject: common.py: use subprocess.check_output instead of os.popen X-Git-Tag: v3.7~29 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=9c196ee599f24a158e6ecab35e04cc14d0cff269;p=recode common.py: use subprocess.check_output instead of os.popen This is more long-winded, but os.popen doesn't seem to work with Unix-style paths on Windows. --- diff --git a/tests/common.py b/tests/common.py index 2bb6bdf..a759aa9 100644 --- a/tests/common.py +++ b/tests/common.py @@ -2,6 +2,7 @@ __metaclass__ = type import os +import subprocess from __main__ import py recode_program = os.environ.get('RECODE') @@ -57,7 +58,12 @@ def external_output(command): if not recode_program: py.test.skip() command = command.replace('$R', recode_program + ' --ignore=:iconv:') - return os.popen(command, 'rb').read() + try: + # FIXME: Find a more portable solution than checking the OS + output = subprocess.check_output(command, universal_newlines=True, shell=os.name != 'nt') + except subprocess.CalledProcessError as e: + output = e.output + return output def recode_output(input): if run.external: