tests: adjust StdoutBuffer for python2/python3 compatibility

io.StringIO expects unicode writes, while string literal on python2 are
bytes. Act accordingly.
This commit is contained in:
Marek Marczykowski-Górecki 2017-03-09 00:17:37 +01:00
parent a575bc3422
commit 6b8bbd9c51
No known key found for this signature in database
GPG Key ID: 063938BA42CFA724

View File

@ -22,9 +22,13 @@
import io import io
import sys import sys
class StdoutBuffer(object): class StdoutBuffer(object):
def __init__(self): def __init__(self):
if sys.version_info[0] >= 3:
self.stdout = io.StringIO() self.stdout = io.StringIO()
else:
self.stdout = io.BytesIO()
def __enter__(self): def __enter__(self):
sys.stdout = self.stdout sys.stdout = self.stdout