Opened 16 years ago

Closed 16 years ago

Last modified 13 years ago

#9480 closed (worksforme)

django.test.client.FakePayload is truncating files

Reported by: hellhound Owned by: nobody
Component: Testing framework Version: 1.0
Severity: Keywords: FakePayload file post client
Cc: Triage Stage: Accepted
Has patch: no Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: no UI/UX: no

Description

The file size is truncated when you pass a file using the post method.

Change History (3)

comment:1 by Jacob, 16 years ago

milestone: 1.1
Triage Stage: UnreviewedAccepted

comment:2 by Russell Keith-Magee, 16 years ago

Resolution: worksforme
Status: newclosed

I can't reproduce this failure. Using the following view:

def file_upload_view(request):
    "A view that validates integrity of file uploads"
    return render_to_response('base.html', {
        'file': request.FILES['file']
    })

the following test case passes without error:

class FileUploadTests(TestCase):
    def test_upload(self):
        testfile = os.path.join(os.path.dirname(__file__), 'fixtures', 'testdata.json')
        f = open(testfile)
        response = self.client.post('/test_client_regress/file_test/', {'file': f})
        f.close()

        self.assertEqual(response.context['file'].size, os.stat(testfile).st_size)
        f.close()

If you can provide a failing test case, please reopen with more details.

comment:3 by Jacob, 13 years ago

milestone: 1.1

Milestone 1.1 deleted

Note: See TracTickets for help on using tickets.
Back to Top