tests: Encode input data for the subprocess

Needed for Python2/3 compatibility.
This commit is contained in:
Tomas Babej 2019-01-01 19:09:38 -05:00 committed by Paul Beckingham
parent 928befeea2
commit b8b06e6680

View file

@ -124,7 +124,7 @@ def _queue_output(arguments, pidq, outputq):
This function is meant to be executed in a thread as it may block This function is meant to be executed in a thread as it may block
""" """
kwargs = arguments["process"] kwargs = arguments["process"]
input = arguments["input"] input_data = arguments["input"].encode("utf-8") if arguments["input"] else None
try: try:
proc = Popen(**kwargs) proc = Popen(**kwargs)
@ -146,7 +146,7 @@ def _queue_output(arguments, pidq, outputq):
pidq.put(proc.pid) pidq.put(proc.pid)
# Send input and wait for finish # Send input and wait for finish
out, err = proc.communicate(input) out, err = proc.communicate(input_data)
if sys.version_info > (3,): if sys.version_info > (3,):
out, err = out.decode('utf-8'), err.decode('utf-8') out, err = out.decode('utf-8'), err.decode('utf-8')