Refs #30422 -- Added test for removing temporary files in MultiPartParser when StopUpload is raised.

This commit is contained in:
aryan 2020-09-28 10:09:29 +02:00 committed by Mariusz Felisiak
parent 5fcfe5361e
commit 21b127bfbc
4 changed files with 30 additions and 2 deletions

View file

@ -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