class documentation

class twisted.trial.runner.TestLoader: (source)

View In Hierarchy

I find tests inside function, modules, files -- whatever -- then return them wrapped inside a Test (either a TestSuite or a TestCase).

Instance Variable methodPrefix A string prefix. TestLoader will assume that all the methods in a class that begin with methodPrefix are test cases.
Instance Variable modulePrefix A string prefix. Every module in a package that begins with modulePrefix is considered a module full of tests.
Instance Variable forceGarbageCollection A flag applied to each TestCase loaded. See unittest.TestCase for more information.
Instance Variable sorter A key function used to sort TestCases, test classes, modules and packages.
Instance Variable suiteFactory A callable which is passed a list of tests (which themselves may be suites of tests). Must return a test suite.
Method __init__ Undocumented
Method sort Sort the given things using sorter.
Method findTestClasses Given a module, return all Trial test classes
Method findByName Find and load tests, given name.
Method loadModule Return a test suite with all the tests from a module.
Method loadClass Given a class which contains test cases, return a list of TestCases.
Method getTestCaseNames Given a class that contains TestCases, return a list of names of methods that probably contain tests.
Method loadMethod Undocumented
Method loadPackage Load tests from a module object representing a package, and return a TestSuite containing those tests.
Method loadDoctests Return a suite of tests for all the doctests defined in module.
Method loadAnything Load absolutely anything (as long as that anything is a module, package, class, or method (with associated parent class and qualname).
Method loadByName Load some tests by name.
Method loadByNames Load some tests by a list of names.
Method loadFile Load a file, and then the tests in that file.
Instance Variable _importErrors Undocumented
Method _makeCase Undocumented
Method _uniqueTests No summary
methodPrefix = (source)
A string prefix. TestLoader will assume that all the methods in a class that begin with methodPrefix are test cases.
(type: str)
modulePrefix = (source)
A string prefix. Every module in a package that begins with modulePrefix is considered a module full of tests.
(type: str)
forceGarbageCollection = (source)
A flag applied to each TestCase loaded. See unittest.TestCase for more information.
sorter = (source)
A key function used to sort TestCases, test classes, modules and packages.
suiteFactory = (source)
A callable which is passed a list of tests (which themselves may be suites of tests). Must return a test suite.
def __init__(self): (source)

Undocumented

_importErrors = (source)

Undocumented

(type: list)
def sort(self, xs): (source)

Sort the given things using sorter.

ParametersxsA list of test cases, class or modules.
def findTestClasses(self, module): (source)

Given a module, return all Trial test classes

def findByName(self, _name, recurse=False): (source)

Find and load tests, given name.

Parameters_nameThe qualified name of the thing to load.
recurseA boolean. If True, inspect modules within packages within the given package (and so on), otherwise, only inspect modules in the package itself.
ReturnsIf name is a filename, return the module. If name is a fully-qualified Python name, return the object it refers to.
def loadModule(self, module): (source)

Return a test suite with all the tests from a module.

Included are TestCase subclasses and doctests listed in the module's __doctests__ module. If that's not good for you, put a function named either testSuite or test_suite in your module that returns a TestSuite, and I'll use the results of that instead.

If testSuite and test_suite are both present, then I'll use testSuite.

def loadClass(self, klass): (source)

Given a class which contains test cases, return a list of TestCases.

ParametersklassThe class to load tests from.
def getTestCaseNames(self, klass): (source)

Given a class that contains TestCases, return a list of names of methods that probably contain tests.

def loadMethod(self, method): (source)

Undocumented

def _makeCase(self, klass, methodName): (source)

Undocumented

def loadPackage(self, package, recurse=False): (source)

Load tests from a module object representing a package, and return a TestSuite containing those tests.

Tests are only loaded from modules whose name begins with 'test_' (or whatever modulePrefix is set to).

Parameterspackagea types.ModuleType object (or reasonable facsimile obtained by importing) which may contain tests.
recurseA boolean. If True, inspect modules within packages within the given package (and so on), otherwise, only inspect modules in the package itself.
Returnsa TestSuite created with my suiteFactory, containing all the tests.
RaisesTypeErrorIf package is not a package.
def loadDoctests(self, module): (source)

Return a suite of tests for all the doctests defined in module.

ParametersmoduleA module object or a module name.
def loadAnything(self, obj, recurse=False, parent=None, qualName=None): (source)

Load absolutely anything (as long as that anything is a module, package, class, or method (with associated parent class and qualname).

ParametersobjThe object to load.
recurseA boolean. If True, inspect modules within packages within the given package (and so on), otherwise, only inspect modules in the package itself.
parentIf obj is a method, this is the parent class of the method. qualName is also required.
qualNameIf obj is a method, this a list containing is the qualified name of the method. parent is also required.
ReturnsA TestCase or TestSuite.
def loadByName(self, name, recurse=False): (source)

Load some tests by name.

ParametersnameThe qualified name for the test to load.
recurseA boolean. If True, inspect modules within packages within the given package (and so on), otherwise, only inspect modules in the package itself.
def loadByNames(self, names, recurse=False): (source)

Load some tests by a list of names.

ParametersnamesA list of qualified names.
recurseA boolean. If True, inspect modules within packages within the given package (and so on), otherwise, only inspect modules in the package itself.
def _uniqueTests(self, things): (source)

Gather unique suite objects from loaded things. This will guarantee uniqueness of inherited methods on TestCases which would otherwise hash to same value and collapse to one test unexpectedly if using simpler means: e.g. set().

def loadFile(self, fileName, recurse=False): (source)

Load a file, and then the tests in that file.

ParametersfileNameThe file name to load.
recurseA boolean. If True, inspect modules within packages within the given package (and so on), otherwise, only inspect modules in the package itself.
API Documentation for Twisted, generated by pydoctor 20.12.1 at 2021-02-28 19:53:36.