README.rst 3.1 KB

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