Ensure that records() always returns a list.
A lot of the code stores the items for later, and using an iterator will result in unhappiness when the data can't be iterated over more than once. Signed-off-by: brian m. carlson <sandals@crustytoothpaste.net>
This commit is contained in:
parent
dc4a1b21e7
commit
daa3d6fef7
2 changed files with 2 additions and 1 deletions
|
|
@ -439,7 +439,7 @@ class Database:
|
|||
if self._needs_upgrade:
|
||||
raise newfol.exception.UpgradeError("Database needs upgrading")
|
||||
if select is not None:
|
||||
return filter(select, self._records)
|
||||
return list(filter(select, self._records))
|
||||
return self._records
|
||||
def location(self):
|
||||
return self._location
|
||||
|
|
|
|||
|
|
@ -176,6 +176,7 @@ class TestDatabaseFiltering(unittest.TestCase):
|
|||
return False
|
||||
return True
|
||||
selected = db.records(has_only_numbers)
|
||||
self.assertEqual(type(selected), list)
|
||||
self.assertEqual(set(selected), set(records[1:]))
|
||||
ddir.cleanup()
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue