gh-68437: Add TestCase.status attribute

This attribute can be used in teardown/cleanup phase to check
status of the test being run.
This commit is contained in:
Jan Musílek 2024-07-13 15:04:11 +02:00
parent 0759cecd9d
commit 9200d2e4b9
5 changed files with 117 additions and 2 deletions

View file

@ -1442,6 +1442,25 @@ Test cases
.. versionadded:: 3.2
.. attribute:: status
This attribute contains resulting status of the single test run.
This can be used to check the test status in :meth:`tearDown` and
cleanup phase. Possible values are ``None`` or any of the values
stored in ``unittest.TestStatus`` enum:
======================= =================================================
Enum name Details
======================= =================================================
``SUCCESS`` Test succeeded.
``UNEXPECTED_SUCCESS`` Test succeeded, but was expected to fail.
``FAILED`` Test failed.
``EXPECTED_FAILURE`` Test failed, as was expected.
``SKIPPED`` Test was skipped.
======================= =================================================
.. versionadded:: 3.14
Testing frameworks can use the following methods to collect information on
the test: