summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
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):