Skip to content
Myr

Merge branch 'test-client-kwargs'

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

Fix #992

authored by Markus Unterwaditzer · committed by Markus Unterwaditzer · parents 6b3fbb3, 986b922 · Browse files · 2 files+25 added−4 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+25 added−4 removed

  • other:+25 added−4 removed

2 files+25 added−4 removed

modified:flask/app.py+20 added-2 removed
819 unmodified lines
820 # resetted normally. This makes it possible to restart the server821 # without reloader and that stuff from an interactive shell.822 self._got_first_request = False823824 def test_client(self, use_cookies=True):824 def test_client(self, use_cookies=True, **kwargs):825 """Creates a test client for this application. For information826 about unit testing head over to :ref:`testing`.827828 Note that if you are testing for assertions or exceptions in your
14 unmodified lines
843 with app.test_client() as c:844 rv = c.get('/?vodka=42')845 assert request.args['vodka'] == '42'846847 Additionally, you may pass optional keyword arguments that will then848 be passed to the application's :attr:`test_client_class` constructor.849 For example::850851 from flask.testing import FlaskClient852853 class CustomClient(FlaskClient):854 def __init__(self, authentication=None, *args, **kwargs):855 FlaskClient.__init__(*args, **kwargs)856 self._authentication = authentication857858 app.test_client_class = CustomClient859 client = app.test_client(authentication='Basic ....')860861 See :class:`~flask.testing.FlaskClient` for more information.862863 .. versionchanged:: 0.4864 added support for `with` block usage for the client.
1 unmodified line
866 .. versionadded:: 0.7867 The `use_cookies` parameter was added as well as the ability868 to override the client to be used by setting the869 :attr:`test_client_class` attribute.870871 .. versionchanged:: 1.0872 Added `**kwargs` to support passing additional keyword arguments to873 the constructor of :attr:`test_client_class`.874 """875 cls = self.test_client_class876 if cls is None:877 from flask.testing import FlaskClient as cls860 return cls(self, self.response_class, use_cookies=use_cookies)878 return cls(self, self.response_class, use_cookies=use_cookies, **kwargs)879880 def open_session(self, request):881 """Creates or opens a new session. Default implementation stores all882 session data in a signed cookie. This requires that the
1025 unmodified lines
modified:CHANGES+5 added-2 removed
6 unmodified lines
7-----------89(release date to be announced, codename to be selected)1011- Added `**kwargs` to :meth:`flask.Test.test_client` to support passing12 additional keyword arguments to the constructor of13 :attr:`flask.Flask.test_client_class`.14- Added ``SESSION_REFRESH_EACH_REQUEST`` config key that controls the15 set-cookie behavior. If set to `True` a permanent session will be16 refreshed each request and get their lifetime extended, if set to17 `False` it will only be modified if the session actually modifies.
4 unmodified lines
22 from a view function.23- Added :meth:`flask.Config.from_json`.24- Added :attr:`flask.Flask.config_class`.25- Added :meth:`flask.config.Config.get_namespace`.23- Added ``TEMPLATES_AUTO_RELOAD`` config key. If disabled the 24 templates will be reloaded only if the application is running in 26- Added ``TEMPLATES_AUTO_RELOAD`` config key. If disabled the27 templates will be reloaded only if the application is running in28 debug mode. For higher performance it’s possible to disable that.29- Added a workaround for a limitation in Python 3.3's namespace loader.30- Added support for explicit root paths when using Python 3.3's namespace31 packages.
505 unmodified lines