djangosnippets.org: Latest snippets tagged with 'lxml'http://djangosnippets.org/tags/lxml/2009-05-29T09:57:37.422670-05:00Cleanup dirty HTML from a WYSIWYG editor
2009-05-29T09:57:37.422670-05:00denishttp://djangosnippets.org/snippets/1536/<p>My admin allows editing of some html fields using TinyMCE, so I end up with horrible code that contains lots of nested <code><p></code>, <code><div></code>, <code><span></code> tags, and style properties which destroy my layout and consistence.</p>
<p>This tag based on lxml tries to kill as much unneeded tags as …</p>
Freely redistributable"Zoom in" on rendered HTML that the test client returns
2009-04-21T15:20:13.610077-05:00peterbehttp://djangosnippets.org/snippets/1455/<p>If you have this as your base class for all unit tests you can do the following:</p>
<pre><code>class TestViews(BaseTestCase):
def test_generated_stats(self):
"test that certain stuff in the response"
...create some content for testing or use fixtures...
response = self.client.get('/some/page/')
# At this point response.content is a huge string filled with …</code></pre>
Freely redistributable