Masked Man Masked Man - 1 year ago 58
HTML Question

Django test can't find br tag

I use linebreaks in template. But the test can't find 'br' tag.

{{ book.short_description | linebreaks }}

This is the test

self.assertContains(response, "New<br></br>Lines")

Answer Source

You need to set html to True in order to handle text as HTML:

self.assertContains(response, "New<br></br>Lines", html=True);

Or you can use assertHTMLEqual. I hope this will help.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download