README.rst 5.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167
  1. .. image:: https://github.com/pytest-dev/pytest/raw/main/doc/en/img/pytest_logo_curves.svg
  2. :target: https://docs.pytest.org/en/stable/
  3. :align: center
  4. :height: 200
  5. :alt: pytest
  6. ------
  7. .. image:: https://img.shields.io/pypi/v/pytest.svg
  8. :target: https://pypi.org/project/pytest/
  9. .. image:: https://img.shields.io/conda/vn/conda-forge/pytest.svg
  10. :target: https://anaconda.org/conda-forge/pytest
  11. .. image:: https://img.shields.io/pypi/pyversions/pytest.svg
  12. :target: https://pypi.org/project/pytest/
  13. .. image:: https://codecov.io/gh/pytest-dev/pytest/branch/main/graph/badge.svg
  14. :target: https://codecov.io/gh/pytest-dev/pytest
  15. :alt: Code coverage Status
  16. .. image:: https://github.com/pytest-dev/pytest/workflows/test/badge.svg
  17. :target: https://github.com/pytest-dev/pytest/actions?query=workflow%3Atest
  18. .. image:: https://results.pre-commit.ci/badge/github/pytest-dev/pytest/main.svg
  19. :target: https://results.pre-commit.ci/latest/github/pytest-dev/pytest/main
  20. :alt: pre-commit.ci status
  21. .. image:: https://img.shields.io/badge/code%20style-black-000000.svg
  22. :target: https://github.com/psf/black
  23. .. image:: https://www.codetriage.com/pytest-dev/pytest/badges/users.svg
  24. :target: https://www.codetriage.com/pytest-dev/pytest
  25. .. image:: https://readthedocs.org/projects/pytest/badge/?version=latest
  26. :target: https://pytest.readthedocs.io/en/latest/?badge=latest
  27. :alt: Documentation Status
  28. .. image:: https://img.shields.io/badge/Discord-pytest--dev-blue
  29. :target: https://discord.com/invite/pytest-dev
  30. :alt: Discord
  31. .. image:: https://img.shields.io/badge/Libera%20chat-%23pytest-orange
  32. :target: https://web.libera.chat/#pytest
  33. :alt: Libera chat
  34. The ``pytest`` framework makes it easy to write small tests, yet
  35. scales to support complex functional testing for applications and libraries.
  36. An example of a simple test:
  37. .. code-block:: python
  38. # content of test_sample.py
  39. def inc(x):
  40. return x + 1
  41. def test_answer():
  42. assert inc(3) == 5
  43. To execute it::
  44. $ pytest
  45. ============================= test session starts =============================
  46. collected 1 items
  47. test_sample.py F
  48. ================================== FAILURES ===================================
  49. _________________________________ test_answer _________________________________
  50. def test_answer():
  51. > assert inc(3) == 5
  52. E assert 4 == 5
  53. E + where 4 = inc(3)
  54. test_sample.py:5: AssertionError
  55. ========================== 1 failed in 0.04 seconds ===========================
  56. Due to ``pytest``'s detailed assertion introspection, only plain ``assert`` statements are used. See `getting-started <https://docs.pytest.org/en/stable/getting-started.html#our-first-test-run>`_ for more examples.
  57. Features
  58. --------
  59. - Detailed info on failing `assert statements <https://docs.pytest.org/en/stable/how-to/assert.html>`_ (no need to remember ``self.assert*`` names)
  60. - `Auto-discovery
  61. <https://docs.pytest.org/en/stable/explanation/goodpractices.html#python-test-discovery>`_
  62. of test modules and functions
  63. - `Modular fixtures <https://docs.pytest.org/en/stable/explanation/fixtures.html>`_ for
  64. managing small or parametrized long-lived test resources
  65. - Can run `unittest <https://docs.pytest.org/en/stable/how-to/unittest.html>`_ (or trial),
  66. `nose <https://docs.pytest.org/en/stable/how-to/nose.html>`_ test suites out of the box
  67. - Python 3.7+ or PyPy3
  68. - Rich plugin architecture, with over 850+ `external plugins <https://docs.pytest.org/en/latest/reference/plugin_list.html>`_ and thriving community
  69. Documentation
  70. -------------
  71. For full documentation, including installation, tutorials and PDF documents, please see https://docs.pytest.org/en/stable/.
  72. Bugs/Requests
  73. -------------
  74. Please use the `GitHub issue tracker <https://github.com/pytest-dev/pytest/issues>`_ to submit bugs or request features.
  75. Changelog
  76. ---------
  77. Consult the `Changelog <https://docs.pytest.org/en/stable/changelog.html>`__ page for fixes and enhancements of each version.
  78. Support pytest
  79. --------------
  80. `Open Collective`_ is an online funding platform for open and transparent communities.
  81. It provides tools to raise money and share your finances in full transparency.
  82. It is the platform of choice for individuals and companies that want to make one-time or
  83. monthly donations directly to the project.
  84. See more details in the `pytest collective`_.
  85. .. _Open Collective: https://opencollective.com
  86. .. _pytest collective: https://opencollective.com/pytest
  87. pytest for enterprise
  88. ---------------------
  89. Available as part of the Tidelift Subscription.
  90. The maintainers of pytest and thousands of other packages are working with Tidelift to deliver commercial support and
  91. maintenance for the open source dependencies you use to build your applications.
  92. Save time, reduce risk, and improve code health, while paying the maintainers of the exact dependencies you use.
  93. `Learn more. <https://tidelift.com/subscription/pkg/pypi-pytest?utm_source=pypi-pytest&utm_medium=referral&utm_campaign=enterprise&utm_term=repo>`_
  94. Security
  95. ^^^^^^^^
  96. pytest has never been associated with a security vulnerability, but in any case, to report a
  97. security vulnerability please use the `Tidelift security contact <https://tidelift.com/security>`_.
  98. Tidelift will coordinate the fix and disclosure.
  99. License
  100. -------
  101. Copyright Holger Krekel and others, 2004.
  102. Distributed under the terms of the `MIT`_ license, pytest is free and open source software.
  103. .. _`MIT`: https://github.com/pytest-dev/pytest/blob/main/LICENSE