from django.template.defaultfilters import removetags from django.test import SimpleTestCase, ignore_warnings from django.utils.deprecation import RemovedInDjango20Warning from django.utils.safestring import mark_safe from ..utils import setup @ignore_warnings(category=RemovedInDjango20Warning) class RemovetagsTests(SimpleTestCase): @setup({'removetags01': '{{ a|removetags:"a b" }} {{ b|removetags:"a b" }}'}) def test_removetags01(self): output = self.engine.render_to_string( 'removetags01', { 'a': 'x
y
', 'b': mark_safe('xy
'), }, ) self.assertEqual(output, 'x <p>y</p> xy
') @setup({'removetags02': '{% autoescape off %}{{ a|removetags:"a b" }} {{ b|removetags:"a b" }}{% endautoescape %}'}) def test_removetags02(self): output = self.engine.render_to_string( 'removetags02', { 'a': 'xy
', 'b': mark_safe('xy
'), }, ) self.assertEqual(output, 'xy
xy
') @ignore_warnings(category=RemovedInDjango20Warning) class FunctionTests(SimpleTestCase): def test_removetags(self): self.assertEqual( removetags( 'some html with disallowed