Skip to content

Commit

Permalink
Fixup empty SimpleSeq unit test
Browse files Browse the repository at this point in the history
  • Loading branch information
NickleDave committed Oct 12, 2024
1 parent 2eee21b commit 64a670f
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions tests/test_formats/test_seq/test_simple.py
Original file line number Diff line number Diff line change
Expand Up @@ -119,9 +119,12 @@ def test_to_file(a_simple_csv_path, tmp_path):
def test_empty_annotations(tmpdir):
# test fix for https://github.com/vocalpy/crowsetta/issues/264
empty_df = pd.DataFrame.from_records([])
with tempfile.NamedTemporaryFile(dir=tmpdir, suffix=".csv") as fp:
# we use a context manager block to work with TemporaryFile before it gets deleted
with tempfile.NamedTemporaryFile(
dir=tmpdir, suffix=".csv"
) as fp:
empty_df.to_csv(fp.name)
# we need to do this all in the context manager block, because the TemporaryFile gets deleted after
fp.close() # on Windows specifically we have to close before we can access, otherwise we get a PermissionsError
simple = crowsetta.formats.seq.SimpleSeq.from_file(annot_path=fp.name)
assert isinstance(simple, crowsetta.formats.seq.SimpleSeq)
for attr in ("onsets_s", "offsets_s", "labels"):
Expand Down

0 comments on commit 64a670f

Please sign in to comment.