I have a Django test that accesses a web page using the Django test client.
In one of the tests, the server returns a ZIP file as an attachment. I access the content of the ZIP file with the following code:
zip_content = StringIO(response.content)
zip = ZipFile(zip_content)
This causes the following deprecation warning:
D:/Developments/Archaeology/DB/ArtefactDatabase/Webserver\importexport\tests\test_import.py:1: DeprecationWarning: Accessing the
content
attribute on a streaming response is deprecated. Use thestreaming_content
attribute instead.`
response.streaming_content
returns some sort of map, which is definitely not a file-like object that's required for ZipFile
. How can I use the streaming_content
attribute for this?
Incidentally, I only get the deprecation warning when passing response.content
to a StringIO
, when I access the response.content of an ordinary HTML page, there's no warning.