Example #1
0
def test_row2dict(db):
    item = db.session.execute(db['table'].select().limit(1)).fetchall()[0]
    assert set(item.keys()) == {'num', 'word'}
    assert set(row2dict(item).keys()) == {'num', 'word'}
    assert isinstance(row2dict(item), OrderedDict)
    assert set(row2dict(item, ignore_keys=('num',)).keys()) == {'word'}
    assert row2dict(item, ignore_keys=('num', 'word')) == OrderedDict()
Example #2
0
 def __iter__(self):
     for item in self.items:
         if hasattr(item, 'keys') and callable(getattr(item, 'keys')):
             yield row2dict(item)
         elif hasattr(item, 'asdict') and callable(getattr(item, 'asdict')):
             yield item.asdict()
         else:
             yield item