Skip to content

Commit

Permalink
Add test showing how format can be misused
Browse files Browse the repository at this point in the history
  • Loading branch information
victorlin committed Jan 22, 2025
1 parent 5fd170e commit fbb56fe
Showing 1 changed file with 13 additions and 0 deletions.
13 changes: 13 additions & 0 deletions tests/io/test_sequences.py
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,19 @@ def test_read_sequences_from_multiple_files_with_different_compression(self, fas
sequences = augur.io.sequences.read_sequences(fasta_filename, gzip_fasta_filename, lzma_fasta_filename, format="fasta")
assert len(list(sequences)) == 9

def test_read_sequences_format_misused(self, fasta_filename):
"""
Specifying a format without the 'format' key name results in the
string being interpreted as a path.
"""
sequences = augur.io.sequences.read_sequences(fasta_filename, "fasta")

# Note: the error is not raised until the "path" is opened.
next(sequences)
with pytest.raises(FileNotFoundError) as e_info:
list(sequences)
assert str(e_info.value).endswith("No such file or directory: 'fasta'")


class TestWriteSequences:
def test_write_sequences(self, tmpdir, sequences):
Expand Down

0 comments on commit fbb56fe

Please sign in to comment.