File: tutorial.rst

package info (click to toggle)
pytest-flask 1.3.0-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 280 kB
  • sloc: python: 553; makefile: 161; sh: 5
file content (60 lines) | stat: -rw-r--r-- 1,484 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
Getting started
===============

Pytest is capable to pick up and run existing tests without any or little
configuration. This section describes how to get started quickly.

Step 1. Install
---------------

``pytest-flask`` is available on `PyPi`_, and can be easily installed via
``pip``::

    pip install pytest-flask


Step 2. Configure
-----------------

Define your application fixture in ``conftest.py``:

.. code:: python

    from myapp import create_app

    @pytest.fixture
    def app():
        app = create_app()
        return app


Step 3. Run your test suite
---------------------------

Use the ``pytest`` command to run your test suite::

    pytest

.. note:: Test discovery.

    Pytest `discovers your tests`_ and has a built-in integration with other
    testing tools (such as ``nose``, ``unittest`` and ``doctest``). More
    comprehensive examples and use cases can be found in the `official
    documentation`_.


What’s next?
------------

The :ref:`features` section gives a more detailed view of available features, as
well as test fixtures and markers.

Consult the `pytest documentation <https://pytest.org/en/latest>`_ for more
information about pytest itself.

If you want to contribute to the project, see the :ref:`contributing` section.


.. _PyPi: https://pypi.org/project/pytest-flask/
.. _discovers your tests: http://docs.pytest.org/en/latest/goodpractices.html#test-discovery
.. _official documentation: http://pytest.org/latest/usage.html