def test_raw_text(self): s = u' This is some text ' x = PurifiedTranslation(localized_string=s) eq_(x.__html__(), 'This is some text')
def test_output(self): assert isinstance(PurifiedTranslation().__html__(), unicode)
def test_truncate_purified_field(): s = '<i>one</i><i>two</i>' t = PurifiedTranslation(localized_string=s) actual = jingo.env.from_string('{{ s|truncate(6) }}').render(s=t) eq_(actual, s)
def test_purified_translation_html(): """__html__() should return a string.""" s = u'<b>heyhey</b>' x = PurifiedTranslation(localized_string=s) assert isinstance(x.__html__(), unicode) eq_(x.__html__(), s)
def test_forbidden_tags(self): s = u'<script>some naughty xss</script>' x = PurifiedTranslation(localized_string=s) eq_(x.__html__(), '<script>some naughty xss</script>')
def test_allowed_tags(self): s = u'<b>bold text</b> or <code>code</code>' x = PurifiedTranslation(localized_string=s) eq_(x.__html__(), u'<b>bold text</b> or <code>code</code>')