Document app.testing=True for test client, #381.
This commit is contained in:
parent
2e5de98297
commit
56177bcbd1
1 changed files with 11 additions and 0 deletions
11
flask/app.py
11
flask/app.py
|
|
@ -716,6 +716,17 @@ class Flask(_PackageBoundObject):
|
|||
"""Creates a test client for this application. For information
|
||||
about unit testing head over to :ref:`testing`.
|
||||
|
||||
Note that if you are testing for assertions or exceptions in your
|
||||
application code, you must set ``app.testing = True`` in order for the
|
||||
exceptions to propagate to the test client. Otherwise, the exception
|
||||
will be handled by the application (not visible to the test client) and
|
||||
the only indication of an AssertionError or other exception will be a
|
||||
500 status code response to the test client. See the :attr:`testing`
|
||||
attribute. For example::
|
||||
|
||||
app.testing = True
|
||||
client = app.test_client()
|
||||
|
||||
The test client can be used in a `with` block to defer the closing down
|
||||
of the context until the end of the `with` block. This is useful if
|
||||
you want to access the context locals for testing::
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue