Commit 8011c6cc authored by BorjaEst's avatar BorjaEst
Browse files

Bugfix metadata deepcopy in source skim

parent b753fb14
......@@ -89,7 +89,8 @@ class Source:
os.makedirs(dirname, exist_ok=True)
logger.info("Skimming data from '%s'", dirname)
with utils.cd(dirname):
metadata = self.metadata.copy()
metadata = {} # copy() does not recurse inside dict
utils.mergedicts(metadata, self.metadata)
utils.mergedicts(metadata, self[model].model.metadata)
_skim(self[model], delta=groupby, metadata=metadata)
......
import copy
import unittest
from o3skim import utils
......@@ -10,7 +11,7 @@ dict_2 = {'b': 2, 'c': 3, 'z': {'b': 2, 'c': 3}}
class Tests_mergedict(unittest.TestCase):
def test_merge_d1d2(self):
dict_3 = dict_1.copy()
dict_3 = copy.deepcopy(dict_1)
utils.mergedicts(dict_3, dict_2)
self.assertEqual(dict_2, {'b': 2, 'c': 3, 'z': {'b': 2, 'c': 3}})
self.assertEqual(dict_3['a'], 1)
......@@ -19,8 +20,8 @@ class Tests_mergedict(unittest.TestCase):
self.assertEqual(dict_3['z'], {'a': 1, 'b': 2, 'c': 3})
def test_merge_d2d1(self):
dict_3 = dict_2.copy()
utils.mergedicts(dict_3, dict_1)
dict_3 = copy.deepcopy(dict_2)
utils.mergedicts(dict_3, dict_1)
self.assertEqual(dict_1, {'a': 1, 'c': 0, 'z': {'a': 1, 'c': 0}})
self.assertEqual(dict_3['a'], 1)
self.assertEqual(dict_3['b'], 2)
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment