Skip to content
Myr

Added the ability to override the test client's class. This fixes #148

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 1640679 · Browse files · 1 file+15 added−3 removed
This commit

State

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

Diff stats

1 file+15 added−3 removed

  • other:+15 added−3 removed

1 file+15 added−3 removed

modified:flask/app.py+15 added-3 removed
197 unmodified lines
198 'SERVER_NAME': None,199 'MAX_CONTENT_LENGTH': None200 })201202 #: the test client that is used with when `test_client` is used.203 #: 204 #: .. versionadded:: 0.7205 test_client_class = None206207 def __init__(self, import_name, static_path=None):208 _PackageBoundObject.__init__(self, import_name)209 if static_path is not None:210 self.static_path = static_path
222 unmodified lines
433 options.setdefault('use_reloader', self.debug)434 options.setdefault('use_debugger', self.debug)435 return run_simple(host, port, self, **options)436432 def test_client(self):437 def test_client(self, use_cookies=True):438 """Creates a test client for this application. For information439 about unit testing head over to :ref:`testing`.440441 The test client can be used in a `with` block to defer the closing down
5 unmodified lines
447 assert request.args['vodka'] == '42'448449 .. versionchanged:: 0.4450 added support for `with` block usage for the client.451452 .. versionadded:: 0.7453 The `use_cookies` parameter was added as well as the ability454 to override the client to be used by setting the455 :attr:`test_client_class` attribute.456 """447 from flask.testing import FlaskClient448 return FlaskClient(self, self.response_class, use_cookies=True)457 cls = self.test_client_class458 if cls is None:459 from flask.testing import FlaskClient as cls460 return cls(self, self.response_class, use_cookies=use_cookies)461462 def open_session(self, request):463 """Creates or opens a new session. Default implementation stores all464 session data in a signed cookie. This requires that the
483 unmodified lines