Skip to content
Myr

Alcoholified placeholders

Before adoption: this commit came in with the history the project adopted, so no landing records it.

authored by Armin Ronacher · committed by Armin Ronacher · parent 52f38bb · Browse files · 2 files+6 added−6 removed
This commit

State

Before adoption: this commit came in with the history the project adopted, so no landing records it.

Diff stats

2 files+6 added−6 removed

  • other:+6 added−6 removed

2 files+6 added−6 removed

modified:docs/testing.rst+2 added-2 removed
231 unmodified lines
232233 app = flask.Flask(__name__)234235 with app.test_client() as c:236 rv = c.get('/?foo=42')237 assert request.args['foo'] == '42'236 rv = c.get('/?tequila=42')237 assert request.args['tequila'] == '42'238239If you would just be using the :meth:`~flask.Flask.test_client` without240the `with` block, the `assert` would fail with an error because `request`241is no longer available (because used outside of an actual request).
3 unmodified lines
modified:flask.py+4 added-4 removed
211 unmodified lines
212213def get_template_attribute(template_name, attribute):214 """Loads a macro (or variable) a template exports. This can be used to215 invoke a macro from within Python code. If you for example have a216 template named `_foo.html` with the following contents:216 template named `_cider.html` with the following contents:217218 .. sourcecode:: html+jinja219220 {% macro hello(name) %}Hello {{ name }}!{% endmacro %}221222 You can access this from Python code like this::223224 hello = get_template_attribute('_foo.html', 'hello')224 hello = get_template_attribute('_cider.html', 'hello')225 return hello('World')226227 .. versionadded:: 0.2228
832 unmodified lines
1061 of the context until the end of the `with` block. This is useful if1062 you want to access the context locals for testing::10631064 with app.test_client() as c:1065 rv = c.get('/?foo=42')1066 assert request.args['foo'] == '42'1065 rv = c.get('/?vodka=42')1066 assert request.args['vodka'] == '42'10671068 .. versionchanged:: 0.41069 added support for `with` block usage for the client.1070 """
442 unmodified lines