summaryrefslogtreecommitdiff
path: root/tests/responses
diff options
context:
space:
mode:
authorJohannes Hoppe <info@johanneshoppe.com>2015-11-11 20:17:32 +0100
committerTim Graham <timograham@gmail.com>2015-12-14 12:46:48 -0500
commit5233b70070f8979f41ca1da2c1b1d78c8e30944e (patch)
tree54993a920bb9df5cdfbbc92dc4fbb010a1d662a5 /tests/responses
parenta6c803a2e3d270818d20f3f0c76e2241de9f0ab1 (diff)
downloaddjango-5233b70070f8979f41ca1da2c1b1d78c8e30944e.tar.gz
Fixed #25725 -- Made HttpReponse immediately close objects.
Diffstat (limited to 'tests/responses')
-rw-r--r--tests/responses/tests.py11
1 files changed, 11 insertions, 0 deletions
diff --git a/tests/responses/tests.py b/tests/responses/tests.py
index 6d0588daa7..5f7a0b5e12 100644
--- a/tests/responses/tests.py
+++ b/tests/responses/tests.py
@@ -5,6 +5,7 @@ from __future__ import unicode_literals
import io
from django.conf import settings
+from django.core.cache import cache
from django.http import HttpResponse
from django.http.response import HttpResponseBase
from django.test import SimpleTestCase
@@ -121,3 +122,13 @@ class HttpResponseTests(SimpleTestCase):
with io.TextIOWrapper(r, UTF8) as buf:
buf.write(content)
self.assertEqual(r.content, content.encode(UTF8))
+
+ def test_generator_cache(self):
+ generator = ("{}".format(i) for i in range(10))
+ response = HttpResponse(content=generator)
+ self.assertEqual(response.content, b'0123456789')
+ self.assertRaises(StopIteration, next, generator)
+
+ cache.set('my-response-key', response)
+ response = cache.get('my-response-key')
+ self.assertEqual(response.content, b'0123456789')