@@ -3,18 +3,36 @@ pytest-flask
3
3
4
4
|PyPI version | |conda-forge version | |Python versions | |ci | |Documentation status |
5
5
6
- An extension of `pytest < http://pytest.org/ >`__ test runner which
6
+ An extension of `pytest `_ test runner which
7
7
provides a set of useful tools to simplify testing and development
8
8
of the Flask extensions and applications.
9
9
10
10
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 `_.
13
13
14
14
How to start?
15
15
-------------
16
16
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 ``:
18
36
19
37
.. code-block :: python
20
38
@@ -25,15 +43,15 @@ Define your application fixture in ``conftest.py``:
25
43
app = create_app()
26
44
return app
27
45
28
- Install the extension with dependencies and go ::
46
+ Finally, install the extension with dependencies and run your test suite ::
29
47
30
48
$ pip install pytest-flask
31
49
$ pytest
32
50
33
51
Contributing
34
52
------------
35
53
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
37
55
suggestion.
38
56
39
57
.. |PyPI version | image :: https://img.shields.io/pypi/v/pytest-flask.svg
@@ -55,3 +73,9 @@ suggestion.
55
73
.. |Documentation status | image :: https://readthedocs.org/projects/pytest-flask/badge/?version=latest
56
74
:target: https://pytest-flask.readthedocs.org/en/latest/
57
75
: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