summaryrefslogtreecommitdiff
path: root/tests/regressiontests
diff options
context:
space:
mode:
authorAymeric Augustin <aymeric.augustin@m4x.org>2012-12-24 20:25:02 +0100
committerAymeric Augustin <aymeric.augustin@m4x.org>2012-12-24 20:30:20 +0100
commitcd914175c8209c5f366e87d94f8f6d050347757d (patch)
tree3a2c7a1b1d8e3df4a82f8fc38cf26a74ce941df0 /tests/regressiontests
parentef98ae2910a6b5c86e1e0b003110455778e63324 (diff)
[1.5.x] Prevented caching of streaming responses.
The test introduced in 4b278131 accidentally passed because of a limitation of Python < 3.3. Refs #17758, #7581. Backport of 1c8be95 from master.
Diffstat (limited to 'tests/regressiontests')
-rw-r--r--tests/regressiontests/cache/tests.py21
1 files changed, 9 insertions, 12 deletions
diff --git a/tests/regressiontests/cache/tests.py b/tests/regressiontests/cache/tests.py
index 9960c01300..cd7da4cece 100644
--- a/tests/regressiontests/cache/tests.py
+++ b/tests/regressiontests/cache/tests.py
@@ -1424,24 +1424,21 @@ class CacheI18nTest(TestCase):
CACHE_MIDDLEWARE_SECONDS=60,
USE_ETAGS=True,
)
- def test_middleware_with_streaming_response(self):
- # cache with non empty request.GET
- request = self._get_request_cache(query_string='foo=baz&other=true')
-
- # first access, cache must return None
+ def test_middleware_doesnt_cache_streaming_response(self):
+ request = self._get_request()
get_cache_data = FetchFromCacheMiddleware().process_request(request)
- self.assertEqual(get_cache_data, None)
+ self.assertIsNone(get_cache_data)
- # pass streaming response through UpdateCacheMiddleware.
- content = 'Check for cache with QUERY_STRING and streaming content'
+ # This test passes on Python < 3.3 even without the corresponding code
+ # in UpdateCacheMiddleware, because pickling a StreamingHttpResponse
+ # fails (http://bugs.python.org/issue14288). LocMemCache silently
+ # swallows the exception and doesn't store the response in cache.
+ content = ['Check for cache with streaming content.']
response = StreamingHttpResponse(content)
UpdateCacheMiddleware().process_response(request, response)
- # second access, cache must still return None, because we can't cache
- # streaming response.
get_cache_data = FetchFromCacheMiddleware().process_request(request)
- self.assertEqual(get_cache_data, None)
-
+ self.assertIsNone(get_cache_data)
@override_settings(
CACHES={