Skip to content

Commit

Permalink
Add context manager for file handling
Browse files Browse the repository at this point in the history
  • Loading branch information
anishTP committed Nov 10, 2023
1 parent f98aa1b commit b5c7b62
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions tests/unit/views/preview_image_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ def test_preview_image_jobs(project_expo2011) -> None:
@pytest.mark.usefixtures('project_expo2011', 'all_fixtures')
def test_preview_image_size(project_expo2011) -> None:
render_project_preview_image(project_id=project_expo2011.id)
preview_image = Image.open(io.BytesIO(project_expo2011.preview_image))
result = from_buffer(io.BytesIO(project_expo2011.preview_image).read(2048), mime=True)
assert preview_image.size == (1280, 720)
assert result == 'image/png'
with Image.open(io.BytesIO(project_expo2011.preview_image)) as preview_image:
assert preview_image.size == (1280, 720)
image_mimetype = from_buffer(io.BytesIO(project_expo2011.preview_image).read(2048), mime=True)
assert image_mimetype == 'image/png'

0 comments on commit b5c7b62

Please sign in to comment.