Skip to content

Commit fcda3c9

Browse files
authored
add create_app context to docs (#128)
1 parent ba6e621 commit fcda3c9

File tree

1 file changed

+30
-6
lines changed

1 file changed

+30
-6
lines changed

README.rst

Lines changed: 30 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3,18 +3,36 @@ pytest-flask
33

44
|PyPI version| |conda-forge version| |Python versions| |ci| |Documentation status|
55

6-
An extension of `pytest <http://pytest.org/>`__ test runner which
6+
An extension of `pytest`_ test runner which
77
provides a set of useful tools to simplify testing and development
88
of the Flask extensions and applications.
99

1010
To view a more detailed list of extension features and examples go to
11-
the `PyPI <https://pypi.python.org/pypi/pytest-flask>`__ overview page or
12-
`package documentation <http://pytest-flask.readthedocs.org/en/latest/>`_.
11+
the `PyPI`_ overview page or
12+
`package documentation`_.
1313

1414
How to start?
1515
-------------
1616

17-
Define your application fixture in ``conftest.py``:
17+
Considering the minimal flask `application factory`_ bellow in ``myapp.py`` as an example:
18+
19+
.. code-block:: python
20+
21+
from flask import Flask
22+
23+
def create_app(config_filename):
24+
# create a minimal app
25+
app = Flask(__name__)
26+
app.config.from_pyfile(config_filename)
27+
28+
# simple hello world view
29+
@app.route('/hello')
30+
def hello():
31+
return 'Hello, World!'
32+
33+
return app
34+
35+
You first need to define your application fixture in ``conftest.py``:
1836

1937
.. code-block:: python
2038
@@ -25,15 +43,15 @@ Define your application fixture in ``conftest.py``:
2543
app = create_app()
2644
return app
2745
28-
Install the extension with dependencies and go::
46+
Finally, install the extension with dependencies and run your test suite::
2947

3048
$ pip install pytest-flask
3149
$ pytest
3250

3351
Contributing
3452
------------
3553

36-
Don’t hesitate to create a `GitHub issue <https://github.com/vitalk/pytest-flask/issues>`__ for any bug or
54+
Don’t hesitate to create a `GitHub issue`_ for any bug or
3755
suggestion.
3856

3957
.. |PyPI version| image:: https://img.shields.io/pypi/v/pytest-flask.svg
@@ -55,3 +73,9 @@ suggestion.
5573
.. |Documentation status| image:: https://readthedocs.org/projects/pytest-flask/badge/?version=latest
5674
:target: https://pytest-flask.readthedocs.org/en/latest/
5775
:alt: Documentation status
76+
77+
.. _pytest: https://docs.pytest.org/en/stable/
78+
.. _PyPI: https://pypi.python.org/pypi/pytest-flask
79+
.. _Github issue: https://github.com/vitalk/pytest-flask/issues
80+
.. _package documentation: http://pytest-flask.readthedocs.org/en/latest/
81+
.. _application factory: https://flask.palletsprojects.com/en/1.1.x/patterns/appfactories/

0 commit comments

Comments
 (0)