#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 , 17 years ago
| milestone: | → 1.1 |
|---|---|
| Triage Stage: | Unreviewed → Accepted |
comment:2 by , 17 years ago
| Resolution: | → worksforme |
|---|---|
| Status: | new → closed |
Note:
See TracTickets
for help on using tickets.
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.