From db93e427af97ac308fa1bab21933a9703cde7770 Mon Sep 17 00:00:00 2001 From: GouravGC Date: Mon, 28 Sep 2026 19:56:51 +0530 Subject: [PATCH] fix: avoid temporary file locking on Windows tests --- tests/test_client.py | 12 ++++++------ tests/test_type_serialization.py | 4 ++-- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/tests/test_client.py b/tests/test_client.py index 7b7ab38e..650983cd 100644 --- a/tests/test_client.py +++ b/tests/test_client.py @@ -461,7 +461,7 @@ def test_client_generate_images(httpserver: HTTPServer): client = Client(httpserver.url_for('/')) - with tempfile.NamedTemporaryFile() as temp: + with tempfile.NamedTemporaryFile(delete=False) as temp: temp.write(PNG_BYTES) temp.flush() response = client.generate('dummy', 'Why is the sky blue?', images=[temp.name]) @@ -851,7 +851,7 @@ def test_client_create_blob(httpserver: HTTPServer): client = Client(httpserver.url_for('/')) - with tempfile.NamedTemporaryFile() as blob: + with tempfile.NamedTemporaryFile(delete=False) as blob: response = client.create_blob(blob.name) assert response == 'sha256:e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855' @@ -861,7 +861,7 @@ def test_client_create_blob_exists(httpserver: HTTPServer): client = Client(httpserver.url_for('/')) - with tempfile.NamedTemporaryFile() as blob: + with tempfile.NamedTemporaryFile(delete=False) as blob: response = client.create_blob(blob.name) assert response == 'sha256:e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855' @@ -1056,7 +1056,7 @@ async def test_async_client_generate_images(httpserver: HTTPServer): client = AsyncClient(httpserver.url_for('/')) - with tempfile.NamedTemporaryFile() as temp: + with tempfile.NamedTemporaryFile(delete=False) as temp: temp.write(PNG_BYTES) temp.flush() response = await client.generate('dummy', 'Why is the sky blue?', images=[temp.name]) @@ -1228,7 +1228,7 @@ async def test_async_client_create_blob(httpserver: HTTPServer): client = AsyncClient(httpserver.url_for('/')) - with tempfile.NamedTemporaryFile() as blob: + with tempfile.NamedTemporaryFile(delete=False) as blob: response = await client.create_blob(blob.name) assert response == 'sha256:e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855' @@ -1238,7 +1238,7 @@ async def test_async_client_create_blob_exists(httpserver: HTTPServer): client = AsyncClient(httpserver.url_for('/')) - with tempfile.NamedTemporaryFile() as blob: + with tempfile.NamedTemporaryFile(delete=False) as blob: response = await client.create_blob(blob.name) assert response == 'sha256:e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855' diff --git a/tests/test_type_serialization.py b/tests/test_type_serialization.py index 02a69e95..05be5ab7 100644 --- a/tests/test_type_serialization.py +++ b/tests/test_type_serialization.py @@ -32,7 +32,7 @@ def test_image_serialization_plain_string(): def test_image_serialization_path(): - with tempfile.NamedTemporaryFile() as temp_file: + with tempfile.NamedTemporaryFile(delete=False) as temp_file: temp_file.write(b'test file content') temp_file.flush() img = Image(value=Path(temp_file.name)) @@ -40,7 +40,7 @@ def test_image_serialization_path(): def test_image_serialization_string_path(): - with tempfile.NamedTemporaryFile() as temp_file: + with tempfile.NamedTemporaryFile(delete=False) as temp_file: temp_file.write(b'test file content') temp_file.flush() img = Image(value=temp_file.name)