From 5be6c7fc60ad9ad20b51abbea92f741f6dd5d046 Mon Sep 17 00:00:00 2001 From: Russell Keith-Magee Date: Sun, 9 May 2010 06:48:32 +0000 Subject: [PATCH] [1.1.X] Fixed #12412 -- Clarified the documentation around file handling by the test client. Thanks to Gabriel Hurley for the draft patch. Backport of r13166 from trunk. git-svn-id: http://code.djangoproject.com/svn/django/branches/releases/1.1.X@13172 bcc190cf-cafb-0310-a4f2-bffc1f526a37 --- docs/topics/testing.txt | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/docs/topics/testing.txt b/docs/topics/testing.txt index 8247f970f9..3ef3ced560 100644 --- a/docs/topics/testing.txt +++ b/docs/topics/testing.txt @@ -577,8 +577,16 @@ arguments at time of construction: (The name ``attachment`` here is not relevant; use whatever name your file-processing code expects.) - Note that you should manually close the file after it has been provided - to ``post()``. + 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 + manually close the file after it has been provided to + ``post()``, as demonstrated above. + + You should also ensure that the file is opened in a way that + allows the data to be read. If your file contains binary data + such as an image, this means you will need to open the file in + ``rb`` (read binary) mode. The ``extra`` argument acts the same as for :meth:`Client.get`.