From 6b8bbd9c51107a1a555cc35fefa0791e91885994 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marek=20Marczykowski-G=C3=B3recki?= Date: Thu, 9 Mar 2017 00:17:37 +0100 Subject: [PATCH] tests: adjust StdoutBuffer for python2/python3 compatibility io.StringIO expects unicode writes, while string literal on python2 are bytes. Act accordingly. --- qubesmgmt/tests/tools/__init__.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/qubesmgmt/tests/tools/__init__.py b/qubesmgmt/tests/tools/__init__.py index ca40d33..464a5e5 100644 --- a/qubesmgmt/tests/tools/__init__.py +++ b/qubesmgmt/tests/tools/__init__.py @@ -22,9 +22,13 @@ import io import sys + class StdoutBuffer(object): def __init__(self): - self.stdout = io.StringIO() + if sys.version_info[0] >= 3: + self.stdout = io.StringIO() + else: + self.stdout = io.BytesIO() def __enter__(self): sys.stdout = self.stdout