diff options
author | Iuri de Silvio <iurisilvio@gmail.com> | 2016-12-18 19:09:26 -0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2016-12-18 19:09:26 -0200 |
commit | 52e547daf9ae120b6e07331e8c5791bb88f911c6 (patch) | |
tree | 4a00603e89e1c0913ba7e57927b7c3f9e68aed69 | |
parent | 7f0b7a0a22281e4f61605e8cec9e50a63170d513 (diff) | |
parent | 91d3299280a57a6780c446c21a506f6259552c0a (diff) | |
download | tablib-52e547daf9ae120b6e07331e8c5791bb88f911c6.tar.gz |
Merge pull request #259 from dyve/master
Fix #260 date and datetime export to JSON
-rw-r--r-- | .gitignore | 3 | ||||
-rw-r--r-- | tablib/formats/_json.py | 6 | ||||
-rwxr-xr-x | test_tablib.py | 23 |
3 files changed, 30 insertions, 2 deletions
@@ -26,3 +26,6 @@ junit-py27.xml # tox noise .tox + +# pyenv noise +.python-version diff --git a/tablib/formats/_json.py b/tablib/formats/_json.py index 777040a..fb66745 100644 --- a/tablib/formats/_json.py +++ b/tablib/formats/_json.py @@ -5,8 +5,10 @@ import tablib -import sys -from tablib.packages import omnijson as json +try: + import json +except ImportError: + from tablib.packages import omnijson as json title = 'json' diff --git a/test_tablib.py b/test_tablib.py index be41ee7..6aa4be4 100755 --- a/test_tablib.py +++ b/test_tablib.py @@ -6,6 +6,9 @@ import json import unittest import sys import os + +import datetime + import tablib from tablib.compat import markup, unicode, is_py3 from tablib.core import Row @@ -381,6 +384,26 @@ class TablibTestCase(unittest.TestCase): data.html data.latex + def test_datetime_append(self): + """Passes in a single datetime and a single date and exports.""" + + new_row = ( + datetime.datetime.now(), + datetime.datetime.today(), + ) + + data.append(new_row) + + data.json + data.yaml + data.csv + data.tsv + data.xls + data.xlsx + data.ods + data.html + data.latex + def test_book_export_no_exceptions(self): """Test that various exports don't error out.""" |