use cStringIO on Python 2.x, io.StringIO on 3.x

This commit is contained in:
Jeremy Carbaugh 2012-03-11 23:17:02 -07:00
parent 79976e3c78
commit 7f69f6a769

View File

@ -1,6 +1,6 @@
from __future__ import unicode_literals from __future__ import unicode_literals
from contextlib import closing from contextlib import closing
from io import BytesIO, StringIO from io import StringIO
import unittest import unittest
from saucebrush.emitters import DebugEmitter, CSVEmitter, CountEmitter from saucebrush.emitters import DebugEmitter, CSVEmitter, CountEmitter
@ -16,8 +16,8 @@ class EmitterTestCase(unittest.TestCase):
def test_csv_emitter(self): def test_csv_emitter(self):
try: try:
import cStringIO # if Python 2.x then use BytesIO import cStringIO # if Python 2.x then use old cStringIO
io = BytesIO() io = cStringIO.StringIO()
except: except:
io = StringIO() # if Python 3.x then use StringIO io = StringIO() # if Python 3.x then use StringIO