mirror of
https://github.com/kennethreitz/tablib.git
synced 2026-06-05 23:10:17 +00:00
Fix unicode encode errors on Python 2 -- Fixes #215
Switch csv library to backports.csv as the implementation is closer to the python 3 one. Add a test case covering the problem. Run tests with unicode_literals from future Fix unicode encode errors with unicode characters - Use `backports.csv` instead of `unicodecsv` - Use StringIO instead of cStringIO - Clean-up some Python 2 specific code
This commit is contained in:
+14
-5
@@ -1,17 +1,17 @@
|
||||
#!/usr/bin/env python
|
||||
# -*- coding: utf-8 -*-
|
||||
"""Tests for Tablib."""
|
||||
|
||||
import json
|
||||
import unittest
|
||||
import sys
|
||||
import os
|
||||
from __future__ import unicode_literals
|
||||
|
||||
import datetime
|
||||
import json
|
||||
import sys
|
||||
import unittest
|
||||
|
||||
import tablib
|
||||
from tablib.compat import markup, unicode, is_py3
|
||||
from tablib.core import Row
|
||||
from tablib.formats import csv as csv_format
|
||||
|
||||
|
||||
class TablibTestCase(unittest.TestCase):
|
||||
@@ -531,6 +531,15 @@ class TablibTestCase(unittest.TestCase):
|
||||
|
||||
self.assertEqual(_csv, data.csv)
|
||||
|
||||
def test_csv_import_set_with_unicode_str(self):
|
||||
"""Import CSV set with non-ascii characters in unicode literal"""
|
||||
csv_text = (
|
||||
"id,givenname,surname,loginname,email,pref_firstname,pref_lastname\n"
|
||||
"13765,Ævar,Arnfjörð,testing,test@example.com,Ævar,Arnfjörð"
|
||||
)
|
||||
data.csv = csv_text
|
||||
self.assertEqual(data.width, 7)
|
||||
|
||||
def test_tsv_import_set(self):
|
||||
"""Generate and import TSV set serialization."""
|
||||
data.append(self.john)
|
||||
|
||||
Reference in New Issue
Block a user