I have the following Django code in my system:
zip_file = zipfile.ZipFile(file, 'r')
for filename in zip_file.namelist():
try:
file_read = zip_file.read(filename)
print(filename)
I am trying to test this code by passing in a zip file from a python TestCase. When I use this code with the web interface, I noticed the zip file is an InMemoryUploadedFile type. So I'm trying to mimic this functionality with my TestCase, but can't seem to create an InMemoryUploadedFile() in my test with a zip file.
I've tried this:
file_name = 'file.zip'
in_memory_uploaded_file = InMemoryUploadedFile(file_name, None, file_name, 'application/zip', 0, None, None)
Any recommendations?