Skip to content
Myr

Document app.testing=True for test client, #381.

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

authored by Ron DuPlain · committed by Ron DuPlain · parent 2e5de98 · Browse files · 1 file+11 added−0 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+11 added−0 removed

  • other:+11 added−0 removed

1 file+11 added−0 removed

modified:flask/app.py+11 added
714 unmodified lines
715 def test_client(self, use_cookies=True):716 """Creates a test client for this application. For information717 about unit testing head over to :ref:`testing`.718719 Note that if you are testing for assertions or exceptions in your720 application code, you must set ``app.testing = True`` in order for the721 exceptions to propagate to the test client. Otherwise, the exception722 will be handled by the application (not visible to the test client) and723 the only indication of an AssertionError or other exception will be a724 500 status code response to the test client. See the :attr:`testing`725 attribute. For example::726727 app.testing = True728 client = app.test_client()729730 The test client can be used in a `with` block to defer the closing down731 of the context until the end of the `with` block. This is useful if732 you want to access the context locals for testing::733
811 unmodified lines