mirror of
https://github.com/django/django.git
synced 2025-10-24 22:26:08 +00:00
Fixed #23911 -- Added support for buffer file uploads in the test client
This commit is contained in:
committed by
Tim Graham
parent
dc2d75f4d4
commit
018d110ef5
@@ -511,6 +511,8 @@ Tests
|
||||
:meth:`TestCase.setUpTestData() <django.test.TestCase.setUpTestData>`. Using
|
||||
this technique can speed up the tests as compared to using ``setUp()``.
|
||||
|
||||
* Added test client support for file uploads with file-like objects.
|
||||
|
||||
Validators
|
||||
^^^^^^^^^^
|
||||
|
||||
|
||||
@@ -238,6 +238,13 @@ Use the ``django.test.Client`` class to make requests.
|
||||
(The name ``attachment`` here is not relevant; use whatever name your
|
||||
file-processing code expects.)
|
||||
|
||||
You may also provide any file-like object (e.g., :class:`~io.StringIO` or
|
||||
:class:`~io.BytesIO`) as a file handle.
|
||||
|
||||
.. versionadded:: 1.8
|
||||
|
||||
The ability to use a file-like object was added.
|
||||
|
||||
Note that if you wish to use the same file handle for multiple
|
||||
``post()`` calls then you will need to manually reset the file
|
||||
pointer between posts. The easiest way to do this is to
|
||||
|
||||
Reference in New Issue
Block a user