Python Glossary Русский

all Python 3unittestfunction

unittest.removeResult()

Ctrl+C handling

Removes a TestResult from those that Ctrl+C stops; it returns True if the result had been registered.

Syntax

unittest.removeResult(result)

After it, Ctrl+C no longer sets shouldStop on this result, and the run carries on as if nothing was pressed. The return value tells 'removed' (True) apart from 'was never registered' (False). It is rarely needed: the module holds weak references, and results drop out of the list by themselves together with the object.

Examples

import unittest
result = unittest.TestResult()
unittest.registerResult(result)
print(unittest.removeResult(result))  # → True
print(unittest.removeResult(result))  # → False

See also

Open in the full glossarydocs.python.orgReport an inaccuracy