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 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