From 15904a51d2e76cf021665ff35800b7c2fc19bda1 Mon Sep 17 00:00:00 2001 From: evilchili Date: Fri, 22 Dec 2023 23:09:43 -0800 Subject: [PATCH] ensure datasources are always DataSource objects --- rolltable/tables.py | 6 +++--- tests/test_tables.py | 5 +++-- 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/rolltable/tables.py b/rolltable/tables.py index 083e2d3..acab4dc 100644 --- a/rolltable/tables.py +++ b/rolltable/tables.py @@ -267,11 +267,11 @@ class RollTable: self._data = [] for src in self._sources: if type(src) is str: - ds = DataSource(src, frequency=self._frequency) + src = [src] + for one_source in src: + ds = DataSource(one_source, frequency=self._frequency) ds.load_source() self._data.append(ds) - else: - self._data.append(src) # merge the headers self._headers = [] diff --git a/tests/test_tables.py b/tests/test_tables.py index 3b745ea..43dd6f7 100644 --- a/tests/test_tables.py +++ b/tests/test_tables.py @@ -205,5 +205,6 @@ def test_text(): def test_as_dict(): - ds = tables.RollTable([fixture_metadata + fixture_source]).datasources[0].as_dict() - assert ds['Option 1']['Header 1'] == 'Option 1' + source = tables.RollTable([fixture_no_descriptions]).datasources[0] + ds = source.as_dict() + assert ds['option 1']['choice'] == 'choice 1'