test_delete_unclaimed_attachments: Close file in make_attachment.

Fixes “ResourceWarning: unclosed file <_io.BufferedReader
name='/srv/zulip/zerver/tests/images/text.txt'>” with warnings enabled.

Signed-off-by: Anders Kaseorg <anders@zulip.com>
This commit is contained in:
Anders Kaseorg 2024-07-16 14:26:36 -07:00 committed by Tim Abbott
parent 325ab83edb
commit c7281b406f
1 changed files with 4 additions and 4 deletions

View File

@ -28,10 +28,10 @@ class UnclaimedAttachmentTest(UploadSerializeMixin, ZulipTestCase):
self.login_user(uploader)
with time_machine.travel(when, tick=False):
file_obj = get_test_image_file(filename)
response = self.assert_json_success(
self.client_post("/json/user_uploads", {"file": file_obj})
)
with get_test_image_file(filename) as file_obj:
response = self.assert_json_success(
self.client_post("/json/user_uploads", {"file": file_obj})
)
path_id = re.sub(r"/user_uploads/", "", response["url"])
return Attachment.objects.get(path_id=path_id)