def test_unicode_writer(self): out = StringIO() writer = utils.UnicodeWriter(out) writer.writerow([ 'abc', u'\xe4\xc3', 123, 1.23, ]) result = out.getvalue() ok_(isinstance(result, str)) u_result = unicode(result, 'utf-8') ok_('abc,' in u_result) ok_(u'\xe4\xc3,' in u_result) ok_('123,' in u_result) ok_('1.23' in u_result)
def test_unicode_writer(): out = StringIO() writer = utils.UnicodeWriter(out) writer.writerow([ 'abc', u'\xe4\xc3', 123, 1.23, ]) #NOTE: This probably needs to be a StringIO in Python 2 and a BytesIO in Python 3 # assuming UnicodeWriter even works in Python 3. I made change to binary_type for # a simple fix until we run python 3 harness test in future. result = out.getvalue() assert isinstance(result, binary_type) u_result = text_type(result, 'utf-8') assert 'abc,' in u_result assert u'\xe4\xc3,' in u_result assert '123,' in u_result assert '1.23' in u_result