summaryrefslogtreecommitdiff
path: root/docs/topics/testing
diff options
context:
space:
mode:
authorRiccardo Magliocchetti <riccardo.magliocchetti@gmail.com>2017-05-06 19:14:15 +0200
committerTim Graham <timograham@gmail.com>2017-05-11 13:59:18 -0400
commitbdf192c59357a0d8117f6f34c94fb32a51e7a774 (patch)
treebd6477057ed840be9ffe8401f7a77073751ac450 /docs/topics/testing
parenta7c6c705e82bfb9f061f35d38c2a6184dae52cd4 (diff)
Fixed #28148 -- Doc'd ImageField name validation concerns with the test client.
Diffstat (limited to 'docs/topics/testing')
-rw-r--r--docs/topics/testing/tools.txt10
1 files changed, 9 insertions, 1 deletions
diff --git a/docs/topics/testing/tools.txt b/docs/topics/testing/tools.txt
index 4f11bd33ff..9755a1b211 100644
--- a/docs/topics/testing/tools.txt
+++ b/docs/topics/testing/tools.txt
@@ -235,7 +235,15 @@ Use the ``django.test.Client`` class to make requests.
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.
+ :class:`~io.BytesIO`) as a file handle. If you're uploading to an
+ :class:`~django.db.models.ImageField`, the object needs a ``name``
+ attribute that passes the
+ :data:`~django.core.validators.validate_image_file_extension` validator.
+ For example::
+
+ >>> from io import BytesIO
+ >>> img = BytesIO(b'mybinarydata')
+ >>> img.name = 'myimage.jpg'
Note that if you wish to use the same file handle for multiple
``post()`` calls then you will need to manually reset the file