diff options
| author | Claude Paroz <claude@2xlibre.net> | 2015-01-21 20:59:40 +0100 |
|---|---|---|
| committer | Claude Paroz <claude@2xlibre.net> | 2015-01-23 08:58:34 +0100 |
| commit | b1bf8d64fbadcab860eb98662c49b8db33db0c3c (patch) | |
| tree | ab937dc2d28b61365152c1cc61492bd79403854e /tests | |
| parent | 7b677fe063910e67dbeb123fcd164305e0425f34 (diff) | |
[1.7.x] Fixed #24193 -- Prevented unclosed file warnings in static.serve()
This regression was caused by 818e59a3f0. The patch is a partial
backport of the new FileResponse class available in later Django
versions.
Thanks Raphaƫl Hertzog for the report, and Tim Graham and Collin
Anderson for the reviews.
Diffstat (limited to 'tests')
| -rw-r--r-- | tests/view_tests/tests/test_static.py | 7 |
1 files changed, 4 insertions, 3 deletions
diff --git a/tests/view_tests/tests/test_static.py b/tests/view_tests/tests/test_static.py index c7a36ce743..1f1ca44c83 100644 --- a/tests/view_tests/tests/test_static.py +++ b/tests/view_tests/tests/test_static.py @@ -5,10 +5,10 @@ from os import path import unittest from django.conf.urls.static import static -from django.http import HttpResponseNotModified +from django.http import FileResponse, HttpResponseNotModified from django.test import SimpleTestCase, override_settings from django.utils.http import http_date -from django.views.static import was_modified_since, STREAM_CHUNK_SIZE +from django.views.static import was_modified_since from .. import urls from ..urls import media_dir @@ -37,10 +37,11 @@ class StaticTests(SimpleTestCase): "The static view should stream files in chunks to avoid large memory usage" response = self.client.get('/%s/%s' % (self.prefix, 'long-line.txt')) first_chunk = next(response.streaming_content) - self.assertEqual(len(first_chunk), STREAM_CHUNK_SIZE) + self.assertEqual(len(first_chunk), FileResponse.block_size) second_chunk = next(response.streaming_content) # strip() to prevent OS line endings from causing differences self.assertEqual(len(second_chunk.strip()), 1449) + response.close() def test_unknown_mime_type(self): response = self.client.get('/%s/file.unknown' % self.prefix) |
