-
Notifications
You must be signed in to change notification settings - Fork 45
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Don't crash if there is a key error in a template. Bug 556814
- Loading branch information
Showing
7 changed files
with
41 additions
and
3 deletions.
There are no files selected for viewing
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
#, python-format | ||
msgid "Broken %(string)s" | ||
msgstr "Broken %(fuuu)s" | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,7 @@ | ||
import os | ||
|
||
# Make filepaths relative to settings. | ||
ROOT = os.path.dirname(os.path.abspath(__file__)) | ||
path = lambda *a: os.path.join(ROOT, *a) | ||
|
||
JINJA_CONFIG = {} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,10 +1,27 @@ | ||
from mock import patch, sentinel | ||
from mock import Mock, patch, sentinel | ||
|
||
from nose.tools import eq_ | ||
from test_helpers import render | ||
import jingo.views | ||
from jingo import get_env | ||
import jinja2 | ||
import tower | ||
|
||
|
||
@patch('jingo.render') | ||
def test_direct_to_template(mock_render): | ||
request = sentinel.request | ||
jingo.views.direct_to_template(request, 'base.html', x=1) | ||
mock_render.assert_called_with(request, 'base.html', {'x': 1}) | ||
|
||
|
||
def test_template_substitution_crash(): | ||
tower.activate('xx') | ||
|
||
env = get_env() | ||
|
||
# The localized string has the wrong variable name in it | ||
s = '{% trans string="heart" %}Broken {{ string }}{% endtrans %}' | ||
template = env.from_string(s) | ||
rendered = jingo.render_to_string(Mock(), template, {}) | ||
eq_(rendered, 'Broken heart') |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters