

def test_replace(self):
    env = Environment()
    tmpl = env.from_string('{{ string|replace("o", 42) }}')
    assert (tmpl.render(string='<foo>') == '<f4242>')
    env = Environment(autoescape=True)
    tmpl = env.from_string('{{ string|replace("o", 42) }}')
    assert (tmpl.render(string='<foo>') == '&lt;f4242&gt;')
    tmpl = env.from_string('{{ string|replace("<", 42) }}')
    assert (tmpl.render(string='<foo>') == '42foo&gt;')
    tmpl = env.from_string('{{ string|replace("o", ">x<") }}')
    assert (tmpl.render(string=Markup('foo')) == 'f&gt;x&lt;&gt;x&lt;')

dataset/ETHPy150Open AppScale/appscale/AppServer/lib/jinja2-2.6/jinja2/testsuite/filters.py FilterTestCase.test_replace/original