<s> from django . utils import translation <EOL> from jinja2 import DictLoader , Environment <EOL> def build_environment ( template ) : <EOL> """<STR_LIT>""" <EOL> env = Environment ( <EOL> autoescape = True , <EOL> loader = DictLoader ( { '<STR_LIT>' : template } ) , <EOL> extensions = [ <EOL> '<STR_LIT>' , <EOL> '<STR_LIT>' <EOL> ] <EOL> ) <EOL> env . install_gettext_translations ( translation , newstyle = True ) <EOL> return env <EOL> def render ( template , * args , ** kwargs ) : <EOL> """<STR_LIT>""" <EOL> env = build_environment ( template ) <EOL> return env . from_string ( template ) . render ( * args , ** kwargs ) <EOL> class TestPuenteI18nExtension : <EOL> def test_gettext ( self ) : <EOL> """<STR_LIT>""" <EOL> tmpl = '<STR_LIT>' <EOL> assert render ( tmpl ) == '<STR_LIT>' <EOL> def test_gettext_is_safe ( self ) : <EOL> """<STR_LIT>""" <EOL> tmpl = '<STR_LIT>' <EOL> assert render ( tmpl ) == '<STR_LIT>' <EOL> def test_gettext_variable_values_notsafe ( self ) : <EOL> """<STR_LIT>""" <EOL> tmpl = '<STR_LIT>' <EOL> assert render ( tmpl ) == '<STR_LIT>' <EOL> def test_gettext_variable_values_autoescape_false ( self ) : <EOL> """<STR_LIT>""" <EOL> tmpl = '<STR_LIT>' <EOL> assert render ( tmpl ) == '<STR_LIT>' <EOL> def test_gettext_variable_values_marked_safe_are_safe ( self ) : <EOL> """<STR_LIT>""" <EOL> tmpl = '<STR_LIT>' <EOL> assert render ( tmpl ) == '<STR_LIT>' <EOL> def test_gettext_format_notsafe ( self ) : <EOL> """<STR_LIT>""" <EOL> tmpl = '<STR_LIT>' <EOL> assert render ( tmpl ) == '<STR_LIT>' <EOL> def test_gettext_format_autoescape_false ( self ) : <EOL> """<STR_LIT>""" <EOL> tmpl = '<STR_LIT>' <EOL> assert render ( tmpl ) == '<STR_LIT>' <EOL> def test_ngettext ( self ) : <EOL> """<STR_LIT>""" <EOL> tmpl = '<STR_LIT>' <EOL> assert render ( tmpl ) == '<STR_LIT>' <EOL> tmpl = '<STR_LIT>' <EOL> assert render ( tmpl ) == '<STR_LIT>' <EOL> def test_ngettext_is_safe ( self ) : <EOL> """<STR_LIT>""" <EOL> tmpl = '<STR_LIT>' <EOL> assert render ( tmpl ) == '<STR_LIT>' <EOL> tmpl = '<STR_LIT>' <EOL> assert render ( tmpl ) == '<STR_LIT>' <EOL> def test_ngettext_variable_num ( self ) : <EOL> """<STR_LIT>""" <EOL> tmpl = '<STR_LIT>' <EOL> assert render ( tmpl ) == '<STR_LIT>' <EOL> tmpl = '<STR_LIT>' <EOL> assert render ( tmpl ) == '<STR_LIT>' <EOL> def test_ngettext_variable_values_notsafe ( self ) : <EOL> """<STR_LIT>""" <EOL> tmpl = '<STR_LIT>' <EOL> assert render ( tmpl ) == '<STR_LIT>' <EOL> tmpl = '<STR_LIT>' <EOL> assert render ( tmpl ) == '<STR_LIT>' <EOL> def test_ngettext_variable_value_marked_safe_is_safe ( self ) : <EOL> tmpl = '<STR_LIT>' <EOL> assert render ( tmpl ) == '<STR_LIT>' <EOL> tmpl = '<STR_LIT>' <EOL> assert render ( tmpl ) == '<STR_LIT>' <EOL> def test_ngettext_variable_values_autoescape_false ( self ) : <EOL> tmpl = ( <EOL> '<STR_LIT>' <EOL> '<STR_LIT>' <EOL> '<STR_LIT>' <EOL> ) <EOL> assert render ( tmpl ) == '<STR_LIT>' <EOL> tmpl = ( <EOL> '<STR_LIT>' <EOL> '<STR_LIT>' <EOL> '<STR_LIT>' <EOL> ) <EOL> assert render ( tmpl ) == '<STR_LIT>' <EOL> def test_pgettext ( self ) : <EOL> tmpl = '<STR_LIT>' <EOL> assert render ( tmpl ) == '<STR_LIT:message>' <EOL> def test_pgettext_is_safe ( self ) : <EOL> tmpl = '<STR_LIT>' <EOL> assert render ( tmpl ) == '<STR_LIT>' <EOL> def test_pgettext_variable_value_notsafe ( self ) : <EOL> tmpl = '<STR_LIT>' <EOL> assert render ( tmpl ) == '<STR_LIT>' <EOL> def test_pgettext_variable_value_marked_safe_is_safe ( self ) : <EOL> tmpl = '<STR_LIT>' <EOL> assert render ( tmpl ) == '<STR_LIT>' <EOL> def test_pgettext_variable_values_autoescape_false ( self ) : <EOL> tmpl = ( <EOL> '<STR_LIT>' <EOL> '<STR_LIT>' <EOL> '<STR_LIT>' <EOL> ) <EOL> assert render ( tmpl ) == '<STR_LIT>' <EOL> def test_npgettext ( self ) : <EOL> tmpl = '<STR_LIT>' <EOL> assert render ( tmpl ) == "<STR_LIT>" <EOL> tmpl = '<STR_LIT>' <EOL> assert render ( tmpl ) == "<STR_LIT>" <EOL> def test_npgettext_is_safe ( self ) : <EOL> tmpl = '<STR_LIT>' <EOL> assert render ( tmpl ) == "<STR_LIT>" <EOL> tmpl = '<STR_LIT>' <EOL> assert render ( tmpl ) == "<STR_LIT>" <EOL> def test_npgettext_variable_num ( self ) : <EOL> tmpl = '<STR_LIT>' <EOL> assert render ( tmpl ) == "<STR_LIT>" <EOL> tmpl = '<STR_LIT>' <EOL> assert render ( tmpl ) == "<STR_LIT>" <EOL> def test_npgettext_variable_values_notsafe ( self ) : <EOL> tmpl = '<STR_LIT>' <EOL> assert render ( tmpl ) == '<STR_LIT>' <EOL> tmpl = '<STR_LIT>' <EOL> assert render ( tmpl ) == '<STR_LIT>' <EOL> def test_npgettext_variable_value_marked_safe_is_safe ( self ) : <EOL> tmpl = '<STR_LIT>' <EOL> assert render ( tmpl ) == '<STR_LIT>' <EOL> tmpl = '<STR_LIT>' <EOL> assert render ( tmpl ) == '<STR_LIT>' <EOL> def test_npgettext_variable_values_autoescape_false ( self ) : <EOL> tmpl = ( <EOL> '<STR_LIT>' <EOL> '<STR_LIT>' <EOL> '<STR_LIT>' <EOL> ) <EOL> assert render ( tmpl ) == '<STR_LIT>' <EOL> tmpl = ( <EOL> '<STR_LIT>' <EOL> '<STR_LIT>' <EOL> '<STR_LIT>' <EOL> ) <EOL> assert render ( tmpl ) == '<STR_LIT>' <EOL> def test_trans ( self ) : <EOL> tmpl = '<STR_LIT>' <EOL> assert render ( tmpl ) == '<STR_LIT>' <EOL> def test_trans_whitespace ( self ) : <EOL> tmpl = ( <EOL> '<STR_LIT>' <EOL> '<STR_LIT>' <EOL> '<STR_LIT>' <EOL> '<STR_LIT>' <EOL> '<STR_LIT>' <EOL> '<STR_LIT>' <EOL> ) <EOL> assert ( <EOL> render ( tmpl ) == <EOL> ( <EOL> '<STR_LIT>' <EOL> '<STR_LIT>' <EOL> '<STR_LIT>' <EOL> ) <EOL> ) <EOL> def test_trans_plural ( self ) : <EOL> tmpl = ( <EOL> '<STR_LIT>' <EOL> '<STR_LIT>' <EOL> '<STR_LIT>' <EOL> '<STR_LIT>' <EOL> '<STR_LIT>' <EOL> '<STR_LIT>' <EOL> '<STR_LIT>' <EOL> ) <EOL> assert ( <EOL> render ( tmpl , count = <NUM_LIT:1> ) == <EOL> ( <EOL> '<STR_LIT>' <EOL> '<STR_LIT>' <EOL> '<STR_LIT>' <EOL> ) <EOL> ) <EOL> assert ( <EOL> render ( tmpl , count = <NUM_LIT:2> ) == <EOL> ( <EOL> '<STR_LIT>' <EOL> '<STR_LIT>' <EOL> '<STR_LIT>' <EOL> ) <EOL> ) <EOL> def test_trans_interpolation ( self ) : <EOL> tmpl = ( <EOL> '<STR_LIT>' <EOL> '<STR_LIT>' <EOL> '<STR_LIT>' <EOL> ) <EOL> assert ( <EOL> render ( tmpl ) == <EOL> '<STR_LIT>' <EOL> ) <EOL> def test_trans_interpolation_with_autoescape_off ( self ) : <EOL> tmpl = ( <EOL> '<STR_LIT>' <EOL> '<STR_LIT>' <EOL> '<STR_LIT>' <EOL> '<STR_LIT>' <EOL> '<STR_LIT>' <EOL> ) <EOL> assert ( <EOL> render ( tmpl ) . strip ( ) == <EOL> '<STR_LIT>' <EOL> ) <EOL> def test_trans_interpolation_and_safe ( self ) : <EOL> tmpl = ( <EOL> '<STR_LIT>' <EOL> '<STR_LIT>' <EOL> '<STR_LIT>' <EOL> ) <EOL> assert ( <EOL> render ( tmpl ) == <EOL> '<STR_LIT>' <EOL> ) <EOL> def test_trans_interpolation_and_safe_with_autoescape_off ( self ) : <EOL> tmpl = ( <EOL> '<STR_LIT>' <EOL> '<STR_LIT>' <EOL> '<STR_LIT>' <EOL> '<STR_LIT>' <EOL> '<STR_LIT>' <EOL> ) <EOL> assert ( <EOL> render ( tmpl ) . strip ( ) == <EOL> '<STR_LIT>' <EOL> ) </s>
