From 21b127bfbc8738705ecee97407161caae612d6b1 Mon Sep 17 00:00:00 2001 From: aryan Date: Mon, 28 Sep 2020 10:09:29 +0200 Subject: Refs #30422 -- Added test for removing temporary files in MultiPartParser when StopUpload is raised. --- tests/file_uploads/uploadhandler.py | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) (limited to 'tests/file_uploads/uploadhandler.py') diff --git a/tests/file_uploads/uploadhandler.py b/tests/file_uploads/uploadhandler.py index 7c6199fd16..9ad335301f 100644 --- a/tests/file_uploads/uploadhandler.py +++ b/tests/file_uploads/uploadhandler.py @@ -2,7 +2,9 @@ Upload handlers to test the upload API. """ -from django.core.files.uploadhandler import FileUploadHandler, StopUpload +from django.core.files.uploadhandler import ( + FileUploadHandler, StopUpload, TemporaryFileUploadHandler, +) class QuotaUploadHandler(FileUploadHandler): @@ -27,6 +29,12 @@ class QuotaUploadHandler(FileUploadHandler): return None +class StopUploadTemporaryFileHandler(TemporaryFileUploadHandler): + """A handler that raises a StopUpload exception.""" + def receive_data_chunk(self, raw_data, start): + raise StopUpload() + + class CustomUploadError(Exception): pass -- cgit v1.3