Skip to content

Commit

Permalink
TST: Fix side effect #2379 (#2395)
Browse files Browse the repository at this point in the history
Issue due to unclosure of temporary file

Closes #2394
  • Loading branch information
pubpub-zz committed Jan 6, 2024
1 parent 85ab279 commit b256965
Showing 1 changed file with 9 additions and 7 deletions.
16 changes: 9 additions & 7 deletions tests/test_writer.py
Original file line number Diff line number Diff line change
Expand Up @@ -224,7 +224,8 @@ def writer_operate(writer: PdfWriter) -> None:
)
def test_writer_operations_by_traditional_usage(convert, needs_cleanup):
if callable(convert):
write_data_here = convert(NamedTemporaryFile(suffix=".pdf", delete=False).name)
with NamedTemporaryFile(suffix=".pdf", delete=False) as fo:
write_data_here = convert(fo.name)
else:
write_data_here = convert

Expand Down Expand Up @@ -254,7 +255,8 @@ def test_writer_operations_by_traditional_usage(convert, needs_cleanup):
)
def test_writer_operations_by_semi_traditional_usage(convert, needs_cleanup):
if callable(convert):
write_data_here = convert(NamedTemporaryFile(suffix=".pdf", delete=False).name)
with NamedTemporaryFile(suffix=".pdf", delete=False) as fo:
write_data_here = convert(fo.name)
else:
write_data_here = convert

Expand All @@ -281,11 +283,10 @@ def test_writer_operations_by_semi_traditional_usage(convert, needs_cleanup):
(BytesIO(), False),
],
)
def test_writer_operations_by_semi_new_traditional_usage(
convert, needs_cleanup
):
def test_writer_operations_by_semi_new_traditional_usage(convert, needs_cleanup):
if callable(convert):
write_data_here = convert(NamedTemporaryFile(suffix=".pdf", delete=False).name)
with NamedTemporaryFile(suffix=".pdf", delete=False) as fo:
write_data_here = convert(fo.name)
else:
write_data_here = convert

Expand All @@ -309,7 +310,8 @@ def test_writer_operations_by_semi_new_traditional_usage(
)
def test_writer_operation_by_new_usage(convert, needs_cleanup):
if callable(convert):
write_data_here = convert(NamedTemporaryFile(suffix=".pdf", delete=False).name)
with NamedTemporaryFile(suffix=".pdf", delete=False) as fo:
write_data_here = convert(fo.name)
else:
write_data_here = convert

Expand Down

0 comments on commit b256965

Please sign in to comment.