mirror of
https://github.com/django/django.git
synced 2025-07-04 01:39:20 +00:00
[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
This commit is contained in:
parent
8d979aecbe
commit
e49fd1ff17
@ -10,7 +10,6 @@ CONTENT = 'a' * FILE_SIZE
|
|||||||
class SendFileTests(TestCase):
|
class SendFileTests(TestCase):
|
||||||
def test_sendfile(self):
|
def test_sendfile(self):
|
||||||
tdir = tempfile.gettempdir()
|
tdir = tempfile.gettempdir()
|
||||||
|
|
||||||
file1 = tempfile.NamedTemporaryFile(suffix=".pdf", dir=tdir)
|
file1 = tempfile.NamedTemporaryFile(suffix=".pdf", dir=tdir)
|
||||||
file1.write(CONTENT)
|
file1.write(CONTENT)
|
||||||
file1.seek(0)
|
file1.seek(0)
|
||||||
@ -18,8 +17,6 @@ class SendFileTests(TestCase):
|
|||||||
response = self.client.get('/sendfile/serve_file/%s/' %
|
response = self.client.get('/sendfile/serve_file/%s/' %
|
||||||
urllib.quote(file1.name))
|
urllib.quote(file1.name))
|
||||||
|
|
||||||
file1.close()
|
|
||||||
|
|
||||||
self.assertEqual(response.status_code, 200)
|
self.assertEqual(response.status_code, 200)
|
||||||
self.assertEqual(response[settings.HTTPRESPONSE_SENDFILE_HEADER],
|
self.assertEqual(response[settings.HTTPRESPONSE_SENDFILE_HEADER],
|
||||||
file1.name)
|
file1.name)
|
||||||
@ -29,8 +26,9 @@ class SendFileTests(TestCase):
|
|||||||
self.assertEqual(response['Content-Type'], 'application/pdf')
|
self.assertEqual(response['Content-Type'], 'application/pdf')
|
||||||
|
|
||||||
# *if* the degraded case is to be supported, add this instead:
|
# *if* the degraded case is to be supported, add this instead:
|
||||||
# self.assertEqual(response.content, CONTENT)
|
self.assertEqual(response.content, CONTENT)
|
||||||
get_content = lambda: response.content
|
get_content = lambda: response.content.read()
|
||||||
self.assertRaises(TypeError, get_content)
|
#self.assertRaises(TypeError, get_content)
|
||||||
|
|
||||||
|
file1.close()
|
||||||
# TODO: test middleware bypass etc
|
# TODO: test middleware bypass etc
|
||||||
|
Loading…
x
Reference in New Issue
Block a user