unittest.TestLoader.sortTestMethodsUsing

sortTestMethodsUsing Function to be used to compare method names when sorting them in getTestCaseNames() and all the loadTestsFrom*() methods.

unittest.TestLoader.loadTestsFromTestCase()

loadTestsFromTestCase(testCaseClass) Return a suite of all tests cases contained in the TestCase-derived testCaseClass. A test case instance is created for each method named by getTestCaseNames(). By default these are the method names beginning with test. If getTestCaseNames() returns no methods, but the runTest() method is implemented, a single test case is created for that method instead.

unittest.TestLoader.loadTestsFromNames()

loadTestsFromNames(names, module=None) Similar to loadTestsFromName(), but takes a sequence of names rather than a single name. The return value is a test suite which supports all the tests defined for each name.

unittest.TestLoader.loadTestsFromName()

loadTestsFromName(name, module=None) Return a suite of all tests cases given a string specifier. The specifier name is a “dotted name” that may resolve either to a module, a test case class, a test method within a test case class, a TestSuite instance, or a callable object which returns a TestCase or TestSuite instance. These checks are applied in the order listed here; that is, a method on a possible test case class will be picked up as “a test method within a test case class”, rather than

unittest.TestLoader.loadTestsFromModule()

loadTestsFromModule(module, pattern=None) Return a suite of all tests cases contained in the given module. This method searches module for classes derived from TestCase and creates an instance of the class for each test method defined for the class. Note While using a hierarchy of TestCase-derived classes can be convenient in sharing fixtures and helper functions, defining test methods on base classes that are not intended to be instantiated directly does not play well with this method. Doi

unittest.TestLoader.getTestCaseNames()

getTestCaseNames(testCaseClass) Return a sorted sequence of method names found within testCaseClass; this should be a subclass of TestCase.

unittest.TestLoader.errors

errors A list of the non-fatal errors encountered while loading tests. Not reset by the loader at any point. Fatal errors are signalled by the relevant a method raising an exception to the caller. Non-fatal errors are also indicated by a synthetic test that will raise the original error when run. New in version 3.5.

unittest.TestLoader.discover()

discover(start_dir, pattern='test*.py', top_level_dir=None) Find all the test modules by recursing into subdirectories from the specified start directory, and return a TestSuite object containing them. Only test files that match pattern will be loaded. (Using shell style pattern matching.) Only module names that are importable (i.e. are valid Python identifiers) will be loaded. All test modules must be importable from the top level of the project. If the start directory is not the top level

unittest.TestLoader

class unittest.TestLoader The TestLoader class is used to create test suites from classes and modules. Normally, there is no need to create an instance of this class; the unittest module provides an instance that can be shared as unittest.defaultTestLoader. Using a subclass or instance, however, allows customization of some configurable properties. TestLoader objects have the following attributes: errors A list of the non-fatal errors encountered while loading tests. Not reset by the load

unittest.TestCase.tearDownClass()

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