Opened 7 years ago

Closed 6 years ago

Last modified 4 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:

Description

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

Change History (3)

comment:1 Changed 6 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 6 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 = 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 Changed 4 years ago by jacob

  • milestone 1.1 deleted

Milestone 1.1 deleted

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