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