From 66466223536a9a33eed273e8e313721e6ed766ef Mon Sep 17 00:00:00 2001 From: Taher Chegini Date: Thu, 7 Nov 2024 20:40:25 -0500 Subject: [PATCH] MNT: Use the current folder for creating temp dir to avoid caveats of using system temp dir. [skip ci] --- tests/test_async_retriever.py | 16 ++++++---------- 1 file changed, 6 insertions(+), 10 deletions(-) diff --git a/tests/test_async_retriever.py b/tests/test_async_retriever.py index 10c565c..91bd0b7 100644 --- a/tests/test_async_retriever.py +++ b/tests/test_async_retriever.py @@ -116,20 +116,16 @@ def test_text_post(): def test_stream(): url = "https://freetestdata.com/wp-content/uploads/2021/09/Free_Test_Data_500KB_CSV-1.csv" - temp = tempfile.NamedTemporaryFile(delete=False) - temp.close() - ar.stream_write([url], [temp.name]) - assert Path(temp.name).stat().st_size == 512789 - Path(temp.name).unlink() + with tempfile.NamedTemporaryFile(dir=".") as temp: + ar.stream_write([url], [temp.name]) + assert Path(temp.name).stat().st_size == 512789 def test_stream_chunked(): url = "https://freetestdata.com/wp-content/uploads/2021/09/Free_Test_Data_500KB_CSV-1.csv" - temp = tempfile.NamedTemporaryFile(delete=False) - temp.close() - ar.stream_write([url], [temp.name], chunk_size=5000) - assert Path(temp.name).stat().st_size == 512789 - Path(temp.name).unlink() + with tempfile.NamedTemporaryFile(dir=".") as temp: + ar.stream_write([url], [temp.name], chunk_size=5000) + assert Path(temp.name).stat().st_size == 512789 def test_ordered_return():