mirror of
https://github.com/kennethreitz/tablib.git
synced 2026-06-05 15:00:19 +00:00
Merge pull request #146 from kennethreitz/fix/unicode_append
Fix test_unicode_append
This commit is contained in:
@@ -5,15 +5,15 @@
|
||||
|
||||
import sys
|
||||
|
||||
|
||||
if sys.version_info[0] > 2:
|
||||
from io import StringIO
|
||||
from io import BytesIO as StringIO
|
||||
from tablib.packages import markup3 as markup
|
||||
else:
|
||||
from cStringIO import StringIO
|
||||
from tablib.packages import markup
|
||||
|
||||
import tablib
|
||||
from tablib.compat import unicode
|
||||
import codecs
|
||||
|
||||
BOOK_ENDINGS = 'h3'
|
||||
@@ -50,7 +50,7 @@ def export_set(dataset):
|
||||
wrapper = codecs.getwriter("utf8")(stream)
|
||||
wrapper.writelines(unicode(page))
|
||||
|
||||
return stream.getvalue()
|
||||
return stream.getvalue().decode('utf-8')
|
||||
|
||||
|
||||
def export_book(databook):
|
||||
|
||||
@@ -58,11 +58,15 @@ def load_workbook(filename, use_iterators = False):
|
||||
|
||||
"""
|
||||
|
||||
if isinstance(filename, file):
|
||||
try:
|
||||
# fileobject must have been opened with 'rb' flag
|
||||
# it is required by zipfile
|
||||
if 'b' not in filename.mode:
|
||||
raise OpenModeError("File-object must be opened in binary mode")
|
||||
except AttributeError:
|
||||
# filename is not an object
|
||||
# it doesn't have mode attribute
|
||||
pass
|
||||
|
||||
try:
|
||||
archive = ZipFile(filename, 'r', ZIP_DEFLATED)
|
||||
|
||||
+7
-3
@@ -1,13 +1,12 @@
|
||||
#!/usr/bin/env python
|
||||
# -*- coding: utf-8 -*-
|
||||
|
||||
"""Tests for Tablib."""
|
||||
|
||||
import unittest
|
||||
import sys
|
||||
import os
|
||||
import tablib
|
||||
from tablib.compat import markup, unicode
|
||||
from tablib.compat import markup, unicode, is_py3
|
||||
|
||||
|
||||
|
||||
@@ -309,7 +308,12 @@ class TablibTestCase(unittest.TestCase):
|
||||
def test_unicode_append(self):
|
||||
"""Passes in a single unicode character and exports."""
|
||||
|
||||
new_row = (u'å', u'é')
|
||||
if is_py3:
|
||||
new_row = ('å', 'é')
|
||||
else:
|
||||
exec("new_row = (u'å', u'é')")
|
||||
|
||||
|
||||
data.append(new_row)
|
||||
|
||||
data.json
|
||||
|
||||
Reference in New Issue
Block a user