Privacy Policy
Snippets index

  Display HTML page from unit test

from tempfile import NamedTemporaryFile

def view_html_page(self, content):
    f = NamedTemporaryFile('w')
    #f.write(unicode(content).encode('utf-8'))
    f.write(content)
    f.flush()
    webbrowser.open('file://'+f.name)
    time.sleep(1)
    f.close()

Sample usage:

self.view_html_page(response.content)