Пример #1
0
 def test_raw_text(self):
     s = u'   This is some text   '
     x = PurifiedTranslation(localized_string=s)
     eq_(x.__html__(), 'This is some text')
Пример #2
0
 def test_output(self):
     assert isinstance(PurifiedTranslation().__html__(), unicode)
Пример #3
0
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)
Пример #4
0
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)
Пример #5
0
 def test_forbidden_tags(self):
     s = u'<script>some naughty xss</script>'
     x = PurifiedTranslation(localized_string=s)
     eq_(x.__html__(), '&lt;script&gt;some naughty xss&lt;/script&gt;')
Пример #6
0
 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>')