From 4395e9493cc33d49b53889f9f726458f05f1a475 Mon Sep 17 00:00:00 2001 From: Sebastien Estienne Date: Sun, 25 Apr 2010 20:44:24 +0800 Subject: [PATCH] add tests for template_filter using a real template --- tests/flask_tests.py | 23 +++++++++++++++++++++++ tests/templates/template_filter.html | 1 + 2 files changed, 24 insertions(+) create mode 100644 tests/templates/template_filter.html diff --git a/tests/flask_tests.py b/tests/flask_tests.py index 6f5a4d38..b976015a 100644 --- a/tests/flask_tests.py +++ b/tests/flask_tests.py @@ -329,6 +329,29 @@ class TemplatingTestCase(unittest.TestCase): assert app.jinja_env.filters['strrev'] == my_reverse assert app.jinja_env.filters['strrev']('abcd') == 'dcba' + def test_template_filter_with_template(self): + app = flask.Flask(__name__) + @app.template_filter() + def super_reverse(s): + return s[::-1] + @app.route('/') + def index(): + return flask.render_template('template_filter.html', value='abcd') + rv = app.test_client().get('/') + assert rv.data == 'dcba' + + def test_template_filter_with_name_and_template(self): + app = flask.Flask(__name__) + @app.template_filter('super_reverse') + def my_reverse(s): + return s[::-1] + @app.route('/') + def index(): + return flask.render_template('template_filter.html', value='abcd') + rv = app.test_client().get('/') + assert rv.data == 'dcba' + + def suite(): from minitwit_tests import MiniTwitTestCase from flaskr_tests import FlaskrTestCase diff --git a/tests/templates/template_filter.html b/tests/templates/template_filter.html new file mode 100644 index 00000000..af46cd94 --- /dev/null +++ b/tests/templates/template_filter.html @@ -0,0 +1 @@ +{{ value|super_reverse }} \ No newline at end of file