From 838cc0f449f96c157cb44eb91984a2753edc7f42 Mon Sep 17 00:00:00 2001 From: Alex Morega Date: Wed, 31 Aug 2022 11:32:18 +0300 Subject: [PATCH] Fixed #33965 -- Improved file-like object example of ImageField in docs. This uses a valid image. --- docs/topics/testing/tools.txt | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/docs/topics/testing/tools.txt b/docs/topics/testing/tools.txt index 8c319287c7..bdbe756a90 100644 --- a/docs/topics/testing/tools.txt +++ b/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