forked from orbit-oss/flask
fix RST line too long
This commit is contained in:
parent
c5c8bbc7f6
commit
6606a4a238
15 changed files with 104 additions and 89 deletions
|
|
@ -73,9 +73,9 @@ this does is disable error catching during request handling, so that
|
|||
you get better error reports when performing test requests against the
|
||||
application.
|
||||
|
||||
Because SQLite3 is filesystem-based, we can easily use the :mod:`tempfile` module
|
||||
to create a temporary database and initialize it. The
|
||||
:func:`~tempfile.mkstemp` function does two things for us: it returns a
|
||||
Because SQLite3 is filesystem-based, we can easily use the
|
||||
:mod:`tempfile` module to create a temporary database and initialize it.
|
||||
The :func:`~tempfile.mkstemp` function does two things for us: it returns a
|
||||
low-level file handle and a random file name, the latter we use as
|
||||
database name. We just have to keep the `db_fd` around so that we can use
|
||||
the :func:`os.close` function to close the file.
|
||||
|
|
@ -93,9 +93,9 @@ If we now run the test suite, we should see the following output::
|
|||
|
||||
=========== no tests ran in 0.07 seconds ============
|
||||
|
||||
Even though it did not run any actual tests, we already know that our ``flaskr``
|
||||
application is syntactically valid, otherwise the import would have died
|
||||
with an exception.
|
||||
Even though it did not run any actual tests, we already know that our
|
||||
``flaskr`` application is syntactically valid, otherwise the import
|
||||
would have died with an exception.
|
||||
|
||||
.. _pytest fixture:
|
||||
https://docs.pytest.org/en/latest/fixture.html
|
||||
|
|
@ -117,11 +117,13 @@ test function to :file:`test_flaskr.py`, like this::
|
|||
Notice that our test functions begin with the word `test`; this allows
|
||||
`pytest`_ to automatically identify the function as a test to run.
|
||||
|
||||
By using ``client.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.
|
||||
By using ``client.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::
|
||||
|
||||
|
|
@ -333,7 +335,8 @@ happen. With Flask 0.4 this is possible by using the
|
|||
|
||||
If you were to use just the :meth:`~flask.Flask.test_client` without
|
||||
the ``with`` block, the ``assert`` would fail with an error because `request`
|
||||
is no longer available (because you are trying to use it outside of the actual request).
|
||||
is no longer available (because you are trying to use it
|
||||
outside of the actual request).
|
||||
|
||||
|
||||
Accessing and Modifying Sessions
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue