diff options
Diffstat (limited to 'docs/topics/testing')
| -rw-r--r-- | docs/topics/testing/tools.txt | 10 |
1 files changed, 9 insertions, 1 deletions
diff --git a/docs/topics/testing/tools.txt b/docs/topics/testing/tools.txt index 9b2e76cadc..1a2e9a847a 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 |
