<s> from __future__ import unicode_literals <EOL> from django . shortcuts import render <EOL> import jinja2 <EOL> from nose . tools import eq_ <EOL> try : <EOL> from unittest . mock import Mock , patch , sentinel <EOL> except ImportError : <EOL> from mock import Mock , patch , sentinel <EOL> import jingo <EOL> from . utils import render as render_string <EOL> @ patch ( '<STR_LIT>' ) <EOL> def test_render ( mock_get_env ) : <EOL> mock_template = Mock ( ) <EOL> mock_env = Mock ( ) <EOL> mock_env . get_template . return_value = mock_template <EOL> mock_get_env . return_value = mock_env <EOL> response = render ( Mock ( ) , sentinel . template , status = <NUM_LIT:32> ) <EOL> mock_env . get_template . assert_called_with ( sentinel . template ) <EOL> assert mock_template . render . called <EOL> eq_ ( response . status_code , <NUM_LIT:32> ) <EOL> @ patch ( '<STR_LIT>' ) <EOL> def test_render_to_string ( mock_get_env ) : <EOL> template = jinja2 . environment . Template ( '<STR_LIT>' ) <EOL> rendered = jingo . render_to_string ( Mock ( ) , template , { '<STR_LIT>' : <NUM_LIT> } ) <EOL> eq_ ( rendered , '<STR_LIT>' ) <EOL> def test_inclusion_tag ( ) : <EOL> @ jingo . register . inclusion_tag ( '<STR_LIT>' ) <EOL> def tag ( x ) : <EOL> return { '<STR_LIT:z>' : x } <EOL> env = jingo . get_env ( ) <EOL> with patch . object ( env , '<STR_LIT>' ) as mock_get_template : <EOL> temp = jinja2 . environment . Template ( '<STR_LIT>' ) <EOL> mock_get_template . return_value = temp <EOL> t = env . from_string ( '<STR_LIT>' ) <EOL> eq_ ( '<STR_LIT>' , t . render ( ) ) <EOL> def test_helpers_loaded ( ) : <EOL> """<STR_LIT>""" <EOL> s = render_string ( '<STR_LIT>' , { } ) <EOL> eq_ ( '<STR_LIT>' , s ) </s>
