README.rst 4.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138
  1. .. image:: https://docs.pytest.org/en/latest/_static/pytest1.png
  2. :target: https://docs.pytest.org/en/latest/
  3. :align: center
  4. :alt: pytest
  5. ------
  6. .. image:: https://img.shields.io/pypi/v/pytest.svg
  7. :target: https://pypi.org/project/pytest/
  8. .. image:: https://img.shields.io/conda/vn/conda-forge/pytest.svg
  9. :target: https://anaconda.org/conda-forge/pytest
  10. .. image:: https://img.shields.io/pypi/pyversions/pytest.svg
  11. :target: https://pypi.org/project/pytest/
  12. .. image:: https://codecov.io/gh/pytest-dev/pytest/branch/master/graph/badge.svg
  13. :target: https://codecov.io/gh/pytest-dev/pytest
  14. :alt: Code coverage Status
  15. .. image:: https://travis-ci.org/pytest-dev/pytest.svg?branch=master
  16. :target: https://travis-ci.org/pytest-dev/pytest
  17. .. image:: https://dev.azure.com/pytest-dev/pytest/_apis/build/status/pytest-CI?branchName=master
  18. :target: https://dev.azure.com/pytest-dev/pytest
  19. .. image:: https://img.shields.io/badge/code%20style-black-000000.svg
  20. :target: https://github.com/python/black
  21. .. image:: https://www.codetriage.com/pytest-dev/pytest/badges/users.svg
  22. :target: https://www.codetriage.com/pytest-dev/pytest
  23. The ``pytest`` framework makes it easy to write small tests, yet
  24. scales to support complex functional testing for applications and libraries.
  25. An example of a simple test:
  26. .. code-block:: python
  27. # content of test_sample.py
  28. def inc(x):
  29. return x + 1
  30. def test_answer():
  31. assert inc(3) == 5
  32. To execute it::
  33. $ pytest
  34. ============================= test session starts =============================
  35. collected 1 items
  36. test_sample.py F
  37. ================================== FAILURES ===================================
  38. _________________________________ test_answer _________________________________
  39. def test_answer():
  40. > assert inc(3) == 5
  41. E assert 4 == 5
  42. E + where 4 = inc(3)
  43. test_sample.py:5: AssertionError
  44. ========================== 1 failed in 0.04 seconds ===========================
  45. Due to ``pytest``'s detailed assertion introspection, only plain ``assert`` statements are used. See `getting-started <https://docs.pytest.org/en/latest/getting-started.html#our-first-test-run>`_ for more examples.
  46. Features
  47. --------
  48. - Detailed info on failing `assert statements <https://docs.pytest.org/en/latest/assert.html>`_ (no need to remember ``self.assert*`` names);
  49. - `Auto-discovery
  50. <https://docs.pytest.org/en/latest/goodpractices.html#python-test-discovery>`_
  51. of test modules and functions;
  52. - `Modular fixtures <https://docs.pytest.org/en/latest/fixture.html>`_ for
  53. managing small or parametrized long-lived test resources;
  54. - Can run `unittest <https://docs.pytest.org/en/latest/unittest.html>`_ (or trial),
  55. `nose <https://docs.pytest.org/en/latest/nose.html>`_ test suites out of the box;
  56. - Python 2.7, Python 3.4+, PyPy 2.3, Jython 2.5 (untested);
  57. - Rich plugin architecture, with over 315+ `external plugins <http://plugincompat.herokuapp.com>`_ and thriving community;
  58. Documentation
  59. -------------
  60. For full documentation, including installation, tutorials and PDF documents, please see https://docs.pytest.org/en/latest/.
  61. Bugs/Requests
  62. -------------
  63. Please use the `GitHub issue tracker <https://github.com/pytest-dev/pytest/issues>`_ to submit bugs or request features.
  64. Changelog
  65. ---------
  66. Consult the `Changelog <https://docs.pytest.org/en/latest/changelog.html>`__ page for fixes and enhancements of each version.
  67. Support pytest
  68. --------------
  69. You can support pytest by obtaining a `Tideflift subscription`_.
  70. Tidelift gives software development teams a single source for purchasing and maintaining their software,
  71. with professional grade assurances from the experts who know it best, while seamlessly integrating with existing tools.
  72. .. _`Tideflift subscription`: https://tidelift.com/subscription/pkg/pypi-pytest?utm_source=pypi-pytest&utm_medium=referral&utm_campaign=readme
  73. Security
  74. ^^^^^^^^
  75. pytest has never been associated with a security vunerability, but in any case, to report a
  76. security vulnerability please use the `Tidelift security contact <https://tidelift.com/security>`_.
  77. Tidelift will coordinate the fix and disclosure.
  78. License
  79. -------
  80. Copyright Holger Krekel and others, 2004-2020.
  81. Distributed under the terms of the `MIT`_ license, pytest is free and open source software.
  82. .. _`MIT`: https://github.com/pytest-dev/pytest/blob/master/LICENSE