1:orphan: 2 3.. _features: 4 5pytest: helps you write better programs 6======================================= 7 8 9The ``pytest`` framework makes it easy to write small tests, yet 10scales to support complex functional testing for applications and libraries. 11 12An example of a simple test: 13 14.. code-block:: python 15 16 # content of test_sample.py 17 def inc(x): 18 return x + 1 19 20 def test_answer(): 21 assert inc(3) == 5 22 23 24To execute it:: 25 26 $ pytest 27 =========================== test session starts ============================ 28 platform linux -- Python 3.x.y, pytest-3.x.y, py-1.x.y, pluggy-0.x.y 29 rootdir: $REGENDOC_TMPDIR, inifile: 30 collected 1 item 31 32 test_sample.py F [100%] 33 34 ================================= FAILURES ================================= 35 _______________________________ test_answer ________________________________ 36 37 def test_answer(): 38 > assert inc(3) == 5 39 E assert 4 == 5 40 E + where 4 = inc(3) 41 42 test_sample.py:5: AssertionError 43 ========================= 1 failed in 0.12 seconds ========================= 44 45Due to ``pytest``'s detailed assertion introspection, only plain ``assert`` statements are used. 46See :ref:`Getting Started <getstarted>` for more examples. 47 48 49Features 50-------- 51 52- Detailed info on failing :ref:`assert statements <assert>` (no need to remember ``self.assert*`` names); 53 54- :ref:`Auto-discovery <test discovery>` of test modules and functions; 55 56- :ref:`Modular fixtures <fixture>` for managing small or parametrized long-lived test resources; 57 58- Can run :ref:`unittest <unittest>` (including trial) and :ref:`nose <noseintegration>` test suites out of the box; 59 60- Python 2.7, Python 3.4+, PyPy 2.3, Jython 2.5 (untested); 61 62- Rich plugin architecture, with over 315+ `external plugins <http://plugincompat.herokuapp.com>`_ and thriving community; 63 64 65Documentation 66------------- 67 68Please see :ref:`Contents <toc>` for full documentation, including installation, tutorials and PDF documents. 69 70 71Bugs/Requests 72------------- 73 74Please use the `GitHub issue tracker <https://github.com/pytest-dev/pytest/issues>`_ to submit bugs or request features. 75 76 77Changelog 78--------- 79 80Consult the :ref:`Changelog <changelog>` page for fixes and enhancements of each version. 81 82 83License 84------- 85 86Copyright Holger Krekel and others, 2004-2017. 87 88Distributed under the terms of the `MIT`_ license, pytest is free and open source software. 89 90.. _`MIT`: https://github.com/pytest-dev/pytest/blob/master/LICENSE 91