Skip to content

Commit

Permalink
empty zipfiles should not raise assertion errors (#1546)
Browse files Browse the repository at this point in the history
  • Loading branch information
ctb authored May 24, 2021
1 parent e47bdb5 commit 83954d1
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/sourmash/sourmash_args.py
Original file line number Diff line number Diff line change
Expand Up @@ -333,7 +333,7 @@ def _load_database(filename, traverse_yield_all, *, cache_size=None):
raise ValueError(f"Error while reading signatures from '{filename}'.")

if loaded: # this is a bit redundant but safe > sorry
assert db
assert db is not None

return db

Expand Down
9 changes: 9 additions & 0 deletions tests/test_sourmash_args.py
Original file line number Diff line number Diff line change
Expand Up @@ -202,3 +202,12 @@ def test_save_signatures_to_location_1_dirout_duplicate(runtmp):
assert ss2 in saved
assert ss47 in saved
assert len(saved) == 4


def test_load_empty_zipfile(runtmp):
outloc = runtmp.output('empty.zip')
with sourmash_args.SaveSignaturesToLocation(outloc) as save_sig:
pass

sigiter = sourmash.load_file_as_signatures(outloc)
assert list(sigiter) == []

0 comments on commit 83954d1

Please sign in to comment.