unittest.TestCase.longMessage

longMessage If set to True then any explicit failure message you pass in to the assert methods will be appended to the end of the normal failure message. The normal messages contain useful information about the objects involved, for example the message from assertEqual shows you the repr of the two unequal objects. Setting this attribute to True allows you to have a custom error message in addition to the normal one. This attribute defaults to True. If set to False then a custom message pass

unittest.TestCase.fail()

fail(msg=None) Signals a test failure unconditionally, with msg or None for the error message.

unittest.TestCase.failureException

failureException This class attribute gives the exception raised by the test method. If a test framework needs to use a specialized exception, possibly to carry additional information, it must subclass this exception in order to “play fair” with the framework. The initial value of this attribute is AssertionError.

unittest.TestCase.id()

id() Return a string identifying the specific test case. This is usually the full name of the test method, including the module and class name.

unittest.TestCase.defaultTestResult()

defaultTestResult() Return an instance of the test result class that should be used for this test case class (if no other result instance is provided to the run() method). For TestCase instances, this will always be an instance of TestResult; subclasses of TestCase should override this as necessary.

unittest.TestCase.doCleanups()

doCleanups() This method is called unconditionally after tearDown(), or after setUp() if setUp() raises an exception. It is responsible for calling all the cleanup functions added by addCleanup(). If you need cleanup functions to be called prior to tearDown() then you can call doCleanups() yourself. doCleanups() pops methods off the stack of cleanup functions one at a time, so it can be called at any time. New in version 3.1.

unittest.TestCase.debug()

debug() Run the test without collecting the result. This allows exceptions raised by the test to be propagated to the caller, and can be used to support running tests under a debugger.

unittest.TestCase.assertWarnsRegex()

assertWarnsRegex(warning, regex, callable, *args, **kwds) assertWarnsRegex(warning, regex, msg=None) Like assertWarns() but also tests that regex matches on the message of the triggered warning. regex may be a regular expression object or a string containing a regular expression suitable for use by re.search(). Example: self.assertWarnsRegex(DeprecationWarning, r'legacy_function\(\) is deprecated', legacy_function, 'XYZ') or: with self.assertWarnsR

unittest.TestCase.countTestCases()

countTestCases() Return the number of tests represented by this test object. For TestCase instances, this will always be 1.

unittest.TestCase.assertWarns()

assertWarns(warning, callable, *args, **kwds) assertWarns(warning, msg=None) Test that a warning is triggered when callable is called with any positional or keyword arguments that are also passed to assertWarns(). The test passes if warning is triggered and fails if it isn’t. Any exception is an error. To catch any of a group of warnings, a tuple containing the warning classes may be passed as warnings. If only the warning and possibly the msg arguments are given, return a context manager so