diff options
| author | Kenneth Reitz <me@kennethreitz.com> | 2010-09-25 18:09:44 -0400 |
|---|---|---|
| committer | Kenneth Reitz <me@kennethreitz.com> | 2010-09-25 18:09:44 -0400 |
| commit | 7f2f925ddb7d47192b79204ccf80e8a9c42f1601 (patch) | |
| tree | 7fd5d775823fdbf6bcbc8334c3335c0a6674fe23 | |
| parent | 3fc898e222c6215c46711d36677f70b8df33eca3 (diff) | |
| download | tablib-7f2f925ddb7d47192b79204ccf80e8a9c42f1601.tar.gz | |
Format Auto-detection in place.
Test suite updated.
| -rw-r--r-- | tablib/__init__.py | 2 | ||||
| -rwxr-xr-x | test_tablib.py | 15 |
2 files changed, 16 insertions, 1 deletions
diff --git a/tablib/__init__.py b/tablib/__init__.py index fadd8dd..e9bdf69 100644 --- a/tablib/__init__.py +++ b/tablib/__init__.py @@ -2,7 +2,7 @@ """ from tablib.core import ( - Databook, Dataset, InvalidDatasetType, + Databook, Dataset, detect, InvalidDatasetType, InvalidDimensions, UnsupportedFormat ) diff --git a/test_tablib.py b/test_tablib.py index 1091390..df9f7bd 100755 --- a/test_tablib.py +++ b/test_tablib.py @@ -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.""" |
