Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[MRG] empty zipfile collections should not raise assertion errors when loaded #1546

Merged
merged 1 commit into from
May 24, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
ctb marked this conversation as resolved.
Show resolved Hide resolved

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) == []