summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorJannis Leidel <jannis@leidel.info>2011-03-02 10:40:48 +0000
committerJannis Leidel <jannis@leidel.info>2011-03-02 10:40:48 +0000
commit6b95aa6fb549b3834b7feefc6fbe92f8a50da411 (patch)
tree3eb61bf9218f53eeb963f89ad10e3e1233a36d2c /tests
parentec193224d3580fbcfa78da96a6a7fc4343929dd8 (diff)
Fixed #15531 -- Partially reverted [15701] due to compatibility issues with middlewares that modify content of responses. Thanks for the report, schinckel. Refs #15281.
git-svn-id: http://code.djangoproject.com/svn/django/trunk@15703 bcc190cf-cafb-0310-a4f2-bffc1f526a37
Diffstat (limited to 'tests')
-rw-r--r--tests/regressiontests/views/tests/static.py24
1 files changed, 8 insertions, 16 deletions
diff --git a/tests/regressiontests/views/tests/static.py b/tests/regressiontests/views/tests/static.py
index 1c4f9ce85b..e3bc1643c5 100644
--- a/tests/regressiontests/views/tests/static.py
+++ b/tests/regressiontests/views/tests/static.py
@@ -26,18 +26,10 @@ class StaticTests(TestCase):
for filename in media_files:
response = self.client.get('/views/%s/%s' % (self.prefix, filename))
file_path = path.join(media_dir, filename)
- content = str(response.content)
- self.assertEquals(open(file_path).read(), content)
- self.assertEquals(len(content), int(response['Content-Length']))
+ self.assertEquals(open(file_path).read(), response.content)
+ self.assertEquals(len(response.content), int(response['Content-Length']))
self.assertEquals(mimetypes.guess_type(file_path)[1], response.get('Content-Encoding', None))
- def test_serve_does_not_buffer_files(self):
- "The static view uses an iterator - see #15281"
- response = self.client.get('/views/%s/file.txt' % self.prefix)
- # response objects can't be used as file-like objects when they are
- # initialized with an iterator
- self.assertRaises(Exception, response.write, 'more text')
-
def test_unknown_mime_type(self):
response = self.client.get('/views/%s/file.unknown' % self.prefix)
self.assertEquals('application/octet-stream', response['Content-Type'])
@@ -76,9 +68,9 @@ class StaticTests(TestCase):
response = self.client.get('/views/%s/%s' % (self.prefix, file_name),
HTTP_IF_MODIFIED_SINCE=invalid_date)
file = open(path.join(media_dir, file_name))
- content = str(response.content)
- self.assertEquals(file.read(), content)
- self.assertEquals(len(content), int(response['Content-Length']))
+ self.assertEquals(file.read(), response.content)
+ self.assertEquals(len(response.content),
+ int(response['Content-Length']))
def test_invalid_if_modified_since2(self):
"""Handle even more bogus If-Modified-Since values gracefully
@@ -90,10 +82,10 @@ class StaticTests(TestCase):
invalid_date = ': 1291108438, Wed, 20 Oct 2010 14:05:00 GMT'
response = self.client.get('/views/%s/%s' % (self.prefix, file_name),
HTTP_IF_MODIFIED_SINCE=invalid_date)
- content = str(response.content)
file = open(path.join(media_dir, file_name))
- self.assertEquals(file.read(), content)
- self.assertEquals(len(content), int(response['Content-Length']))
+ self.assertEquals(file.read(), response.content)
+ self.assertEquals(len(response.content),
+ int(response['Content-Length']))
class StaticHelperTest(StaticTests):