METADATA 6.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206
  1. Metadata-Version: 2.1
  2. Name: pytest-subtests
  3. Version: 0.9.0
  4. Summary: unittest subTest() support and subtests fixture
  5. Home-page: https://github.com/pytest-dev/pytest-subtests
  6. Author: Bruno Oliveira
  7. Author-email: nicoddemus@gmail.com
  8. Maintainer: Bruno Oliveira
  9. Maintainer-email: nicoddemus@gmail.com
  10. License: MIT
  11. Classifier: Development Status :: 4 - Beta
  12. Classifier: Framework :: Pytest
  13. Classifier: Intended Audience :: Developers
  14. Classifier: Topic :: Software Development :: Testing
  15. Classifier: Programming Language :: Python
  16. Classifier: Programming Language :: Python :: 3
  17. Classifier: Programming Language :: Python :: 3.7
  18. Classifier: Programming Language :: Python :: 3.8
  19. Classifier: Programming Language :: Python :: 3.9
  20. Classifier: Programming Language :: Python :: 3.10
  21. Classifier: Programming Language :: Python :: 3.11
  22. Classifier: Programming Language :: Python :: Implementation :: CPython
  23. Classifier: Operating System :: OS Independent
  24. Classifier: License :: OSI Approved :: MIT License
  25. Requires-Python: >=3.7
  26. License-File: LICENSE
  27. Requires-Dist: pytest (>=7.0)
  28. ===============
  29. pytest-subtests
  30. ===============
  31. unittest ``subTest()`` support and ``subtests`` fixture.
  32. .. image:: https://img.shields.io/pypi/v/pytest-subtests.svg
  33. :target: https://pypi.org/project/pytest-subtests
  34. :alt: PyPI version
  35. .. image:: https://img.shields.io/conda/vn/conda-forge/pytest-subtests.svg
  36. :target: https://anaconda.org/conda-forge/pytest-subtests
  37. .. image:: https://img.shields.io/pypi/pyversions/pytest-subtests.svg
  38. :target: https://pypi.org/project/pytest-subtests
  39. :alt: Python versions
  40. .. image:: https://github.com/pytest-dev/pytest-subtests/workflows/build/badge.svg
  41. :target: https://github.com/pytest-dev/pytest-subtests/actions
  42. .. image:: https://img.shields.io/badge/code%20style-black-000000.svg
  43. :target: https://github.com/ambv/black
  44. ----
  45. This `pytest`_ plugin was generated with `Cookiecutter`_ along with `@hackebrot`_'s `cookiecutter-pytest-plugin`_ template.
  46. Features
  47. --------
  48. * Adds support for `TestCase.subTest <https://docs.python.org/3/library/unittest.html#distinguishing-test-iterations-using-subtests>`__.
  49. * New ``subtests`` fixture, providing similar functionality for pure pytest tests.
  50. Installation
  51. ------------
  52. You can install ``pytest-subtests`` via `pip`_ from `PyPI`_::
  53. $ pip install pytest-subtests
  54. Usage
  55. -----
  56. unittest subTest() example
  57. ^^^^^^^^^^^^^^^^^^^^^^^^^^
  58. .. code-block:: python
  59. import unittest
  60. class T(unittest.TestCase):
  61. def test_foo(self):
  62. for i in range(5):
  63. with self.subTest("custom message", i=i):
  64. self.assertEqual(i % 2, 0)
  65. if __name__ == "__main__":
  66. unittest.main()
  67. **Output**
  68. .. code-block::
  69. λ pytest .tmp\test-unit-subtest.py
  70. ======================== test session starts ========================
  71. ...
  72. collected 1 item
  73. .tmp\test-unit-subtest.py FF. [100%]
  74. ============================= FAILURES ==============================
  75. _________________ T.test_foo [custom message] (i=1) _________________
  76. self = <test-unit-subtest.T testMethod=test_foo>
  77. def test_foo(self):
  78. for i in range(5):
  79. with self.subTest('custom message', i=i):
  80. > self.assertEqual(i % 2, 0)
  81. E AssertionError: 1 != 0
  82. .tmp\test-unit-subtest.py:9: AssertionError
  83. _________________ T.test_foo [custom message] (i=3) _________________
  84. self = <test-unit-subtest.T testMethod=test_foo>
  85. def test_foo(self):
  86. for i in range(5):
  87. with self.subTest('custom message', i=i):
  88. > self.assertEqual(i % 2, 0)
  89. E AssertionError: 1 != 0
  90. .tmp\test-unit-subtest.py:9: AssertionError
  91. ================ 2 failed, 1 passed in 0.07 seconds =================
  92. ``subtests`` fixture example
  93. ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  94. .. code-block:: python
  95. def test(subtests):
  96. for i in range(5):
  97. with subtests.test(msg="custom message", i=i):
  98. assert i % 2 == 0
  99. **Output**
  100. .. code-block::
  101. λ pytest .tmp\test-subtest.py
  102. ======================== test session starts ========================
  103. ...
  104. collected 1 item
  105. .tmp\test-subtest.py .F.F.. [100%]
  106. ============================= FAILURES ==============================
  107. ____________________ test [custom message] (i=1) ____________________
  108. def test(subtests):
  109. for i in range(5):
  110. with subtests.test(msg='custom message', i=i):
  111. > assert i % 2 == 0
  112. E assert (1 % 2) == 0
  113. .tmp\test-subtest.py:4: AssertionError
  114. ____________________ test [custom message] (i=3) ____________________
  115. def test(subtests):
  116. for i in range(5):
  117. with subtests.test(msg='custom message', i=i):
  118. > assert i % 2 == 0
  119. E assert (3 % 2) == 0
  120. .tmp\test-subtest.py:4: AssertionError
  121. ================ 2 failed, 1 passed in 0.07 seconds =================
  122. Contributing
  123. ------------
  124. Contributions are very welcome. Tests can be run with `tox`_:
  125. .. code-block::
  126. tox -e py37
  127. License
  128. -------
  129. Distributed under the terms of the `MIT`_ license, "pytest-subtests" is free and open source software
  130. Issues
  131. ------
  132. If you encounter any problems, please `file an issue`_ along with a detailed description.
  133. .. _`Cookiecutter`: https://github.com/audreyr/cookiecutter
  134. .. _`@hackebrot`: https://github.com/hackebrot
  135. .. _`MIT`: http://opensource.org/licenses/MIT
  136. .. _`BSD-3`: http://opensource.org/licenses/BSD-3-Clause
  137. .. _`GNU GPL v3.0`: http://www.gnu.org/licenses/gpl-3.0.txt
  138. .. _`Apache Software License 2.0`: http://www.apache.org/licenses/LICENSE-2.0
  139. .. _`cookiecutter-pytest-plugin`: https://github.com/pytest-dev/cookiecutter-pytest-plugin
  140. .. _`file an issue`: https://github.com/pytest-dev/pytest-subtests/issues
  141. .. _`pytest`: https://github.com/pytest-dev/pytest
  142. .. _`tox`: https://tox.readthedocs.io/en/latest/
  143. .. _`pip`: https://pypi.org/project/pip/
  144. .. _`PyPI`: https://pypi.org/project