unittest.TestCase.subTest()

subTest(msg=None, **params) Return a context manager which executes the enclosed code block as a subtest. msg and params are optional, arbitrary values which are displayed whenever a subtest fails, allowing you to identify them clearly. A test case can contain any number of subtest declarations, and they can be arbitrarily nested. See Distinguishing test iterations using subtests for more information. New in version 3.4.

unittest.TestCase.tearDown()

tearDown() Method called immediately after the test method has been called and the result recorded. This is called even if the test method raised an exception, so the implementation in subclasses may need to be particularly careful about checking internal state. Any exception, other than AssertionError or SkipTest, raised by this method will be considered an additional error rather than a test failure (thus increasing the total number of reported errors). This method will only be called if t

unittest.TestCase.skipTest()

skipTest(reason) Calling this during a test method or setUp() skips the current test. See Skipping tests and expected failures for more information. New in version 3.1.

unittest.TestCase.setUpClass()

setUpClass() A class method called before tests in an individual class run. setUpClass is called with the class as the only argument and must be decorated as a classmethod(): @classmethod def setUpClass(cls): ... See Class and Module Fixtures for more details. New in version 3.2.

unittest.TestCase.shortDescription()

shortDescription() Returns a description of the test, or None if no description has been provided. The default implementation of this method returns the first line of the test method’s docstring, if available, or None. Changed in version 3.1: In 3.1 this was changed to add the test name to the short description even in the presence of a docstring. This caused compatibility issues with unittest extensions and adding the test name was moved to the TextTestResult in Python 3.2.

unittest.TestCase.run()

run(result=None) Run the test, collecting the result into the TestResult object passed as result. If result is omitted or None, a temporary result object is created (by calling the defaultTestResult() method) and used. The result object is returned to run()‘s caller. The same effect may be had by simply calling the TestCase instance. Changed in version 3.3: Previous versions of run did not return the result. Neither did calling an instance.

unittest.TestCase.setUp()

setUp() Method called to prepare the test fixture. This is called immediately before calling the test method; other than AssertionError or SkipTest, any exception raised by this method will be considered an error rather than a test failure. The default implementation does nothing.

unittest.TestCase.records

records A list of logging.LogRecord objects of the matching log messages.

unittest.TestCase.output

output A list of str objects with the formatted output of matching messages.

unittest.TestCase.maxDiff

maxDiff This attribute controls the maximum length of diffs output by assert methods that report diffs on failure. It defaults to 80*8 characters. Assert methods affected by this attribute are assertSequenceEqual() (including all the sequence comparison methods that delegate to it), assertDictEqual() and assertMultiLineEqual(). Setting maxDiff to None means that there is no maximum length of diffs. New in version 3.2.