|
|
|
@ -311,6 +311,32 @@ class TemplatingTestCase(unittest.TestCase):
|
|
|
|
|
macro = flask.get_template_attribute('_macro.html', 'hello') |
|
|
|
|
assert macro('World') == 'Hello World!' |
|
|
|
|
|
|
|
|
|
def test_template_filter_not_called(self): |
|
|
|
|
app = flask.Flask(__name__) |
|
|
|
|
@app.template_filter |
|
|
|
|
def my_reverse(s): |
|
|
|
|
return s[::-1] |
|
|
|
|
assert 'my_reverse' in app.jinja_env.filters.keys() |
|
|
|
|
assert app.jinja_env.filters['my_reverse'] == my_reverse |
|
|
|
|
assert app.jinja_env.filters['my_reverse']('abcd') == 'dcba' |
|
|
|
|
|
|
|
|
|
def test_template_filter_called(self): |
|
|
|
|
app = flask.Flask(__name__) |
|
|
|
|
@app.template_filter() |
|
|
|
|
def my_reverse(s): |
|
|
|
|
return s[::-1] |
|
|
|
|
assert 'my_reverse' in app.jinja_env.filters.keys() |
|
|
|
|
assert app.jinja_env.filters['my_reverse'] == my_reverse |
|
|
|
|
assert app.jinja_env.filters['my_reverse']('abcd') == 'dcba' |
|
|
|
|
|
|
|
|
|
def test_template_filter_with_name(self): |
|
|
|
|
app = flask.Flask(__name__) |
|
|
|
|
@app.template_filter('strrev') |
|
|
|
|
def my_reverse(s): |
|
|
|
|
return s[::-1] |
|
|
|
|
assert 'strrev' in app.jinja_env.filters.keys() |
|
|
|
|
assert app.jinja_env.filters['strrev'] == my_reverse |
|
|
|
|
assert app.jinja_env.filters['strrev']('abcd') == 'dcba' |
|
|
|
|
|
|
|
|
|
def suite(): |
|
|
|
|
from minitwit_tests import MiniTwitTestCase |
|
|
|
|