def test_list_extender(self): """list_adder should add items to list, creating if necessary""" d = dummy() list_extender(d, 'x', '345') self.assertEqual(d.x, ['3','4','5']) list_extender(d, 'x', 'abc') self.assertEqual(d.x, ['3','4','5','a','b','c']) list_extender(d, 'y', [2,3]) self.assertEqual(d.x, ['3','4','5','a','b','c']) self.assertEqual(d.y, [2,3]) list_extender(d, 'y', None) self.assertEqual(d.y, [2,3,None])
def _pmid_adder(obj, field, line): """Adds pmid to relevant field""" list_extender(obj, field, _read_pmid(line))