Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 6 additions & 6 deletions tests/test_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -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])
Expand Down Expand Up @@ -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'

Expand All @@ -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'

Expand Down Expand Up @@ -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])
Expand Down Expand Up @@ -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'

Expand All @@ -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'

Expand Down
4 changes: 2 additions & 2 deletions tests/test_type_serialization.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,15 +32,15 @@ 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))
assert img.model_dump() == b64encode(b'test file content').decode()


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)
Expand Down