Fixes #274 - Fix Databook.load() params ordering

This commit is contained in:
Claude Paroz
2018-07-07 14:09:28 +02:00
parent a0df54ca22
commit 8ea082ce60
3 changed files with 11 additions and 1 deletions
+4
View File
@@ -1,5 +1,9 @@
# History # History
## Unreleased
- Fixed `DataBook().load` parameter ordering (first stream, then format).
## 0.11.5 (2017-06-13) ## 0.11.5 (2017-06-13)
- Use `yaml.safe_load` for importing yaml. - Use `yaml.safe_load` for importing yaml.
+1 -1
View File
@@ -1089,7 +1089,7 @@ class Databook(object):
"""The number of the :class:`Dataset` objects within :class:`Databook`.""" """The number of the :class:`Dataset` objects within :class:`Databook`."""
return len(self._datasets) 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`. Import `in_stream` to the :class:`Databook` object using the `format`.
+6
View File
@@ -806,6 +806,9 @@ class JSONTests(BaseTestCase):
book.json = _json book.json = _json
self.assertEqual(json.loads(_json), json.loads(book.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): def test_json_import_set(self):
"""Generate and import JSON set serialization.""" """Generate and import JSON set serialization."""
@@ -862,6 +865,9 @@ class YAMLTests(BaseTestCase):
book.yaml = _yaml book.yaml = _yaml
self.assertEqual(_yaml, book.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): def test_yaml_import_set(self):
"""Generate and import YAML set serialization.""" """Generate and import YAML set serialization."""