updated docs to match new Werkzeug docs
This commit is contained in:
parent
4c76607553
commit
10159e5464
7 changed files with 82 additions and 78 deletions
|
|
@ -13,11 +13,11 @@ safely change things, and you will instantly know if your change broke
|
|||
something.
|
||||
|
||||
Flask gives you a couple of ways to test applications. It mainly does
|
||||
that by exposing the Werkzeug test :class:`~werkzeug.Client` class to your
|
||||
code and handling the context locals for you. You can then use that with
|
||||
your favourite testing solution. In this documentation we will use the
|
||||
:mod:`unittest` package that comes preinstalled with each Python
|
||||
installation.
|
||||
that by exposing the Werkzeug test :class:`~werkzeug.test.Client` class
|
||||
to your code and handling the context locals for you. You can then use
|
||||
that with your favourite testing solution. In this documentation we
|
||||
will use the :mod:`unittest` package that comes preinstalled with each
|
||||
Python installation.
|
||||
|
||||
The Application
|
||||
---------------
|
||||
|
|
@ -106,13 +106,13 @@ this::
|
|||
rv = self.app.get('/')
|
||||
assert 'No entries here so far' in rv.data
|
||||
|
||||
Test functions begin with the word `test`. Every function named like that
|
||||
will be picked up automatically. By using `self.app.get` we can send an
|
||||
HTTP `GET` request to the application with the given path. The return
|
||||
value will be a :class:`~flask.Flask.response_class` object. We can now
|
||||
use the :attr:`~werkzeug.BaseResponse.data` attribute to inspect the
|
||||
return value (as string) from the application. In this case, we ensure
|
||||
that ``'No entries here so far'`` is part of the output.
|
||||
Test functions begin with the word `test`. Every function named like
|
||||
that will be picked up automatically. By using `self.app.get` we can
|
||||
send an HTTP `GET` request to the application with the given path.
|
||||
The return value will be a :class:`~flask.Flask.response_class` object.
|
||||
We can now use the :attr:`~werkzeug.wrappers.BaseResponse.data` attribute
|
||||
to inspect the return value (as string) from the application. In this
|
||||
case, we ensure that ``'No entries here so far'`` is part of the output.
|
||||
|
||||
Run it again and you should see one passing test::
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue