Opened 8 years ago

Closed 7 years ago

Last modified 5 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: UI/UX:


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

Change History (3)

comment:1 Changed 8 years ago by jacob

  • milestone set to 1.1
  • Needs documentation unset
  • Needs tests unset
  • Patch needs improvement unset
  • Triage Stage changed from Unreviewed to Accepted

comment:2 Changed 7 years ago by russellm

  • Resolution set to worksforme
  • Status changed from new to closed

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 ='/test_client_regress/file_test/', {'file': f})

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

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

comment:3 Changed 5 years ago by jacob

  • milestone 1.1 deleted

Milestone 1.1 deleted

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