mirror of
https://github.com/kennethreitz/tablib.git
synced 2026-06-05 23:10:17 +00:00
Fix: Circular reference detected error (#332)
* Rename function name * Add uuid handler on json dumps * Add myself to authors
This commit is contained in:
committed by
Iuri de Silvio
parent
38486231cc
commit
3d5943a8a4
@@ -6,6 +6,7 @@ import doctest
|
||||
import json
|
||||
import unittest
|
||||
import sys
|
||||
from uuid import uuid4
|
||||
|
||||
import datetime
|
||||
|
||||
@@ -226,6 +227,22 @@ class TablibTestCase(unittest.TestCase):
|
||||
|
||||
# Delete from invalid index
|
||||
self.assertRaises(IndexError, self.founders.__delitem__, 3)
|
||||
|
||||
def test_json_export(self):
|
||||
"""Verify exporting dataset object as JSON"""
|
||||
|
||||
address_id = uuid4()
|
||||
headers = self.headers + ('address_id',)
|
||||
founders = tablib.Dataset(headers=headers, title='Founders')
|
||||
founders.append(('John', 'Adams', 90, address_id))
|
||||
founders_json = founders.export('json')
|
||||
|
||||
expected_json = (
|
||||
'[{"first_name": "John", "last_name": "Adams", "gpa": 90, '
|
||||
'"address_id": "%s"}]' % str(address_id)
|
||||
)
|
||||
|
||||
self.assertEqual(founders_json, expected_json)
|
||||
|
||||
def test_csv_export(self):
|
||||
"""Verify exporting dataset object as CSV."""
|
||||
|
||||
Reference in New Issue
Block a user