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:
parent
a575bc3422
commit
6b8bbd9c51
@ -22,9 +22,13 @@
|
|||||||
import io
|
import io
|
||||||
import sys
|
import sys
|
||||||
|
|
||||||
|
|
||||||
class StdoutBuffer(object):
|
class StdoutBuffer(object):
|
||||||
def __init__(self):
|
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):
|
def __enter__(self):
|
||||||
sys.stdout = self.stdout
|
sys.stdout = self.stdout
|
||||||
|
Loading…
Reference in New Issue
Block a user