Browse Source

Fixed #33965 -- Improved file-like object example of ImageField in docs.

This uses a valid image.
Alex Morega 2 years ago
parent
commit
838cc0f449
1 changed files with 5 additions and 2 deletions
  1. 5 2
      docs/topics/testing/tools.txt

+ 5 - 2
docs/topics/testing/tools.txt

@@ -257,8 +257,11 @@ Use the ``django.test.Client`` class to make requests.
         For example::
 
             >>> from io import BytesIO
-            >>> img = BytesIO(b'mybinarydata')
-            >>> img.name = 'myimage.jpg'
+            >>> img = BytesIO(
+            ...     b"GIF89a\x01\x00\x01\x00\x00\x00\x00!\xf9\x04\x01\x00\x00\x00"
+            ...     b"\x00,\x00\x00\x00\x00\x01\x00\x01\x00\x00\x02\x01\x00\x00"
+            ... )
+            >>> img.name = "myimage.gif"
 
         Note that if you wish to use the same file handle for multiple
         ``post()`` calls then you will need to manually reset the file