summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChris Cahoon <chris.cahoon@gmail.com>2009-07-09 19:53:12 +0000
committerChris Cahoon <chris.cahoon@gmail.com>2009-07-09 19:53:12 +0000
commite49fd1ff17865f541fd3346de26cf1158ab0d257 (patch)
tree8d7d958cc24efbb41a6405fe742a74ea496f8412
parent8d979aecbeeac180a4e21922df68b9f41ba2fa50 (diff)
downloaddjango-e49fd1ff17865f541fd3346de26cf1158ab0d257.tar.gz
[soc2009/http-wsgi-improvement] Repairs to initial regressiontests.sendfile test to fix temp file usage.
git-svn-id: http://code.djangoproject.com/svn/django/branches/soc2009/http-wsgi-improvements@11210 bcc190cf-cafb-0310-a4f2-bffc1f526a37
-rw-r--r--tests/regressiontests/sendfile/tests.py10
1 files changed, 4 insertions, 6 deletions
diff --git a/tests/regressiontests/sendfile/tests.py b/tests/regressiontests/sendfile/tests.py
index b1f1fdff14..cdae1db60f 100644
--- a/tests/regressiontests/sendfile/tests.py
+++ b/tests/regressiontests/sendfile/tests.py
@@ -10,7 +10,6 @@ CONTENT = 'a' * FILE_SIZE
class SendFileTests(TestCase):
def test_sendfile(self):
tdir = tempfile.gettempdir()
-
file1 = tempfile.NamedTemporaryFile(suffix=".pdf", dir=tdir)
file1.write(CONTENT)
file1.seek(0)
@@ -18,8 +17,6 @@ class SendFileTests(TestCase):
response = self.client.get('/sendfile/serve_file/%s/' %
urllib.quote(file1.name))
- file1.close()
-
self.assertEqual(response.status_code, 200)
self.assertEqual(response[settings.HTTPRESPONSE_SENDFILE_HEADER],
file1.name)
@@ -29,8 +26,9 @@ class SendFileTests(TestCase):
self.assertEqual(response['Content-Type'], 'application/pdf')
# *if* the degraded case is to be supported, add this instead:
- # self.assertEqual(response.content, CONTENT)
- get_content = lambda: response.content
- self.assertRaises(TypeError, get_content)
+ self.assertEqual(response.content, CONTENT)
+ get_content = lambda: response.content.read()
+ #self.assertRaises(TypeError, get_content)
+ file1.close()
# TODO: test middleware bypass etc