Attempt to get these tests working on python 2.6

This commit is contained in:
Leo Simons 2014-08-06 13:58:27 +02:00 committed by wilderrodrigues
parent e405e94797
commit f593255371
1 changed files with 28 additions and 0 deletions

View File

@ -16,6 +16,34 @@
# under the License.
from __future__ import with_statement
# install subprocess.check_output for 2.4 =< python < 2.7
try:
from subprocess import check_output
except (NameError, ImportError):
import subprocess
def check_output(*popenargs, **kwargs):
r"""Run command with arguments and return its output as a byte string.
Backported from Python 2.7 as it's implemented as pure python on stdlib.
>>> check_output(['/usr/bin/python', '--version'])
Python 2.6.2
"""
process = subprocess.Popen(stdout=subprocess.PIPE, *popenargs, **kwargs)
output, unused_err = process.communicate()
retcode = process.poll()
if retcode:
cmd = kwargs.get("args")
if cmd is None:
cmd = popenargs[0]
error = subprocess.CalledProcessError(retcode, cmd)
error.output = output
raise error
return output
subprocess.check_output
from vagrant import Vagrant
from unittest import TestCase
from paramiko.config import SSHConfig