1.. image:: http://docs.pytest.org/en/latest/_static/pytest1.png
2   :target: http://docs.pytest.org
3   :align: center
4   :alt: pytest
5
6------
7
8.. image:: https://img.shields.io/pypi/v/pytest.svg
9    :target: https://pypi.org/project/pytest/
10
11.. image:: https://img.shields.io/conda/vn/conda-forge/pytest.svg
12    :target: https://anaconda.org/conda-forge/pytest
13
14.. image:: https://img.shields.io/pypi/pyversions/pytest.svg
15    :target: https://pypi.org/project/pytest/
16
17.. image:: https://img.shields.io/coveralls/pytest-dev/pytest/master.svg
18    :target: https://coveralls.io/r/pytest-dev/pytest
19
20.. image:: https://travis-ci.org/pytest-dev/pytest.svg?branch=master
21    :target: https://travis-ci.org/pytest-dev/pytest
22
23.. image:: https://ci.appveyor.com/api/projects/status/mrgbjaua7t33pg6b?svg=true
24    :target: https://ci.appveyor.com/project/pytestbot/pytest
25
26.. image:: https://img.shields.io/badge/code%20style-black-000000.svg
27  :target: https://github.com/ambv/black
28
29.. image:: https://www.codetriage.com/pytest-dev/pytest/badges/users.svg
30    :target: https://www.codetriage.com/pytest-dev/pytest
31
32The ``pytest`` framework makes it easy to write small tests, yet
33scales to support complex functional testing for applications and libraries.
34
35An example of a simple test:
36
37.. code-block:: python
38
39    # content of test_sample.py
40    def inc(x):
41        return x + 1
42
43
44    def test_answer():
45        assert inc(3) == 5
46
47
48To execute it::
49
50    $ pytest
51    ============================= test session starts =============================
52    collected 1 items
53
54    test_sample.py F
55
56    ================================== FAILURES ===================================
57    _________________________________ test_answer _________________________________
58
59        def test_answer():
60    >       assert inc(3) == 5
61    E       assert 4 == 5
62    E        +  where 4 = inc(3)
63
64    test_sample.py:5: AssertionError
65    ========================== 1 failed in 0.04 seconds ===========================
66
67
68Due to ``pytest``'s detailed assertion introspection, only plain ``assert`` statements are used. See `getting-started <http://docs.pytest.org/en/latest/getting-started.html#our-first-test-run>`_ for more examples.
69
70
71Features
72--------
73
74- Detailed info on failing `assert statements <http://docs.pytest.org/en/latest/assert.html>`_ (no need to remember ``self.assert*`` names);
75
76- `Auto-discovery
77  <http://docs.pytest.org/en/latest/goodpractices.html#python-test-discovery>`_
78  of test modules and functions;
79
80- `Modular fixtures <http://docs.pytest.org/en/latest/fixture.html>`_ for
81  managing small or parametrized long-lived test resources;
82
83- Can run `unittest <http://docs.pytest.org/en/latest/unittest.html>`_ (or trial),
84  `nose <http://docs.pytest.org/en/latest/nose.html>`_ test suites out of the box;
85
86- Python 2.7, Python 3.4+, PyPy 2.3, Jython 2.5 (untested);
87
88- Rich plugin architecture, with over 315+ `external plugins <http://plugincompat.herokuapp.com>`_ and thriving community;
89
90
91Documentation
92-------------
93
94For full documentation, including installation, tutorials and PDF documents, please see http://docs.pytest.org.
95
96
97Bugs/Requests
98-------------
99
100Please use the `GitHub issue tracker <https://github.com/pytest-dev/pytest/issues>`_ to submit bugs or request features.
101
102
103Changelog
104---------
105
106Consult the `Changelog <http://docs.pytest.org/en/latest/changelog.html>`__ page for fixes and enhancements of each version.
107
108
109License
110-------
111
112Copyright Holger Krekel and others, 2004-2017.
113
114Distributed under the terms of the `MIT`_ license, pytest is free and open source software.
115
116.. _`MIT`: https://github.com/pytest-dev/pytest/blob/master/LICENSE
117