Format Auto-detection in place.

Test suite updated.
This commit is contained in:
Kenneth Reitz
2010-09-25 18:09:44 -04:00
parent 3fc898e222
commit 7f2f925ddb
2 changed files with 16 additions and 1 deletions
+1 -1
View File
@@ -2,7 +2,7 @@
"""
from tablib.core import (
Databook, Dataset, InvalidDatasetType,
Databook, Dataset, detect, InvalidDatasetType,
InvalidDimensions, UnsupportedFormat
)
+15
View File
@@ -300,6 +300,21 @@ class TablibTestCase(unittest.TestCase):
self.assertFalse(tablib.formats.yaml.detect(_bunk))
def test_auto_format_detect(self):
"""Test auto format detection."""
_yaml = '- {age: 90, first_name: John, last_name: Adams}'
_json = '[{"last_name": "Adams","age": 90,"first_name": "John"}]'
_csv = '1,2,3\n4,5,6\n7,8,9\n'
_bunk = '¡¡¡¡¡¡---///\n\n\n¡¡£™∞¢£§∞§¶•¶ª∞¶•ªº••ª–º§•†•§º¶•†¥ª–º•§ƒø¥¨©πƒø†ˆ¥ç©¨√øˆ¥≈†ƒ¥ç©ø¨çˆ¥ƒçø¶'
self.assertEqual(tablib.detect(_yaml)[0], tablib.formats.yaml)
self.assertEqual(tablib.detect(_csv)[0], tablib.formats.csv)
self.assertEqual(tablib.detect(_json)[0], tablib.formats.json)
self.assertEqual(tablib.detect(_bunk)[0], None)
def test_wipe(self):
"""Purge a dataset."""