Skip to content

Commit

Permalink
pytest-dev#2692: Document setup/teardown behaviour when using unittes…
Browse files Browse the repository at this point in the history
…t-based suites
  • Loading branch information
OwenTuz committed Oct 21, 2017
1 parent 4cb60da commit 1fcca7b
Showing 1 changed file with 12 additions and 1 deletion.
13 changes: 12 additions & 1 deletion doc/en/unittest.rst
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ their ``test`` methods in ``test_*.py`` or ``*_test.py`` files.
Almost all ``unittest`` features are supported:

* ``@unittest.skip`` style decorators;
* ``setUp/tearDown``;
* ``setUp/tearDown`` (see :ref:`note regarding test phases` below);
* ``setUpClass/tearDownClass()``;

.. _`load_tests protocol`: https://docs.python.org/3/library/unittest.html#load-tests-protocol
Expand Down Expand Up @@ -233,3 +233,14 @@ was executed ahead of the ``test_method``.
overwrite ``unittest.TestCase`` ``__call__`` or ``run``, they need to
to overwrite ``debug`` in the same way (this is also true for standard
unittest).

.. _note_regarding_test_phases:
.. note::

Due to architectural differences between the two frameworks, setup and
teardown for ``unittest``-based tests is performed during the ``call`` phase
of testing instead of in ``pytest``'s standard ``setup`` and ``teardown``
stages. This can be important to understand in some situations, particularly
when reasoning about errors. For example, if a ``unittest``-based suite
exhibits errors during setup, ``pytest`` will report no errors during its
``setup`` phase and will instead raise the error during ``call``.

0 comments on commit 1fcca7b

Please sign in to comment.