Using Five testbrowser to test file downloads

Fabio Corneti info at corneti.com
Mon Sep 17 20:01:12 UTC 2007


I have created a simple view which has a method to stream a file on  
the filesystem; basically the method does the following stuff:

self.request.response.setHeader('Content-Type', 'application/pdf')
self.request.response.setHeader('Content-Disposition',  
'attachment;filename=%s' % download_filename)
self.request.response.write(buffer)

I can test the headers with browser.headers, but I haven't be able to  
test the response, which is always set to an empty string.

 >>> browser.headers['Content-Type'] == 'application/pdf'
True
 >>> browser.headers['Content-Disposition'] ==  
'attachment;filename=1.05.000.01_02_2_0B.pdf'
True
 >>> browser.contents == ''
True
 >>> browser.mech_browser.response().read() == ''
True

Is this a limitation of Five testbrowser? I'm using Five 1.4.2 on  
Plone 2.5.3.

Best,
Fabio Corneti
info at corneti.com




More information about the Product-Developers mailing list