unittest.TestCase.addCleanup()

addCleanup(function, *args, **kwargs) Add a function to be called after tearDown() to cleanup resources used during the test. Functions will be called in reverse order to the order they are added (LIFO). They are called with any arguments and keyword arguments passed into addCleanup() when they are added. If setUp() fails, meaning that tearDown() is not called, then any cleanup functions added will still be called. New in version 3.1.

unittest.TestCase.assertAlmostEqual()

assertAlmostEqual(first, second, places=7, msg=None, delta=None) assertNotAlmostEqual(first, second, places=7, msg=None, delta=None) Test that first and second are approximately (or not approximately) equal by computing the difference, rounding to the given number of decimal places (default 7), and comparing to zero. Note that these methods round the values to the given number of decimal places (i.e. like the round() function) and not significant digits. If delta is supplied instead of places

unittest.TestCase.addTypeEqualityFunc()

addTypeEqualityFunc(typeobj, function) Registers a type-specific method called by assertEqual() to check if two objects of exactly the same typeobj (not subclasses) compare equal. function must take two positional arguments and a third msg=None keyword argument just as assertEqual() does. It must raise self.failureException(msg) when inequality between the first two parameters is detected – possibly providing useful information and explaining the inequalities in details in the error message.

unittest.SkipTest

exception unittest.SkipTest(reason) This exception is raised to skip a test. Usually you can use TestCase.skipTest() or one of the skipping decorators instead of raising this directly.

unittest.skipUnless()

@unittest.skipUnless(condition, reason) Skip the decorated test unless condition is true.

unittest.skipIf()

@unittest.skipIf(condition, reason) Skip the decorated test if condition is true.

unittest.removeHandler()

unittest.removeHandler(function=None) When called without arguments this function removes the control-c handler if it has been installed. This function can also be used as a test decorator to temporarily remove the handler whilst the test is being executed: @unittest.removeHandler def test_signal_handling(self): ...

unittest.removeResult()

unittest.removeResult(result) Remove a registered result. Once a result has been removed then stop() will no longer be called on that result object in response to a control-c.

unittest.skip()

@unittest.skip(reason) Unconditionally skip the decorated test. reason should describe why the test is being skipped.

unittest.mock.sentinel

unittest.mock.sentinel The sentinel object provides a convenient way of providing unique objects for your tests. Attributes are created on demand when you access them by name. Accessing the same attribute will always return the same object. The objects returned have a sensible repr so that test failure messages are readable.