summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorClaude Paroz <claude@2xlibre.net>2018-07-07 14:09:28 +0200
committerClaude Paroz <claude@2xlibre.net>2019-10-04 09:36:42 +0200
commit8ea082ce604c9517bc999fc9af2a26e5eff19f7e (patch)
tree1b9ac77a3750591755dfe510f921583d6000d528
parenta0df54ca2234f904dcc1ccc189cbcd173d59f691 (diff)
downloadtablib-8ea082ce604c9517bc999fc9af2a26e5eff19f7e.tar.gz
Fixes #274 - Fix Databook.load() params ordering
-rw-r--r--HISTORY.md4
-rw-r--r--tablib/core.py2
-rwxr-xr-xtest_tablib.py6
3 files changed, 11 insertions, 1 deletions
diff --git a/HISTORY.md b/HISTORY.md
index f23994f..0ca5e5d 100644
--- a/HISTORY.md
+++ b/HISTORY.md
@@ -1,5 +1,9 @@
# History
+## Unreleased
+
+- Fixed `DataBook().load` parameter ordering (first stream, then format).
+
## 0.11.5 (2017-06-13)
- Use `yaml.safe_load` for importing yaml.
diff --git a/tablib/core.py b/tablib/core.py
index e5244f6..6c4a4bf 100644
--- a/tablib/core.py
+++ b/tablib/core.py
@@ -1089,7 +1089,7 @@ class Databook(object):
"""The number of the :class:`Dataset` objects within :class:`Databook`."""
return len(self._datasets)
- def load(self, format, in_stream, **kwargs):
+ def load(self, in_stream, format, **kwargs):
"""
Import `in_stream` to the :class:`Databook` object using the `format`.
diff --git a/test_tablib.py b/test_tablib.py
index 9cbc6c8..758ac91 100755
--- a/test_tablib.py
+++ b/test_tablib.py
@@ -806,6 +806,9 @@ class JSONTests(BaseTestCase):
book.json = _json
self.assertEqual(json.loads(_json), json.loads(book.json))
+ # Same with the load interface
+ book2 = tablib.Databook().load(_json, None)
+ self.assertEqual(json.loads(book.json), json.loads(book2.json))
def test_json_import_set(self):
"""Generate and import JSON set serialization."""
@@ -862,6 +865,9 @@ class YAMLTests(BaseTestCase):
book.yaml = _yaml
self.assertEqual(_yaml, book.yaml)
+ # Same with the load interface
+ book2 = tablib.Databook().load(_yaml, None)
+ self.assertEqual(_yaml, book2.yaml)
def test_yaml_import_set(self):
"""Generate and import YAML set serialization."""