t.t.r.TestLoader(object) : class documentation

Part of twisted.trial.runner View 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 Return a Python object given a string describing it.
Method loadModule Return a test suite with all the tests from a module.
Method loadClass Given a class which contains test cases, return a sorted list of TestCase instances.
Method getTestCaseNames Given a class that contains TestCases, return a list of names of methods that probably contain tests.
Method loadMethod Given a method of a TestCase that represents a test, return a TestCase instance for that test.
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 Given a Python object, return whatever tests that are in it. Whatever 'in' might mean.
Method loadByName Given a string representing a Python object, return whatever tests are in that object.
Method loadByNames No summary
Method _makeCase Undocumented
Method _uniqueTests No summary
methodPrefix =
A string prefix. TestLoader will assume that all the methods in a class that begin with methodPrefix are test cases.
modulePrefix =
A string prefix. Every module in a package that begins with modulePrefix is considered a module full of tests.
forceGarbageCollection =
A flag applied to each TestCase loaded. See unittest.TestCase for more information.
sorter =
A key function used to sort TestCases, test classes, modules and packages.
suiteFactory =
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
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): (source)
Return a Python object given a string describing it.
Parametersnamea string which may be either a filename or a fully-qualified Python name.
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 sorted list of TestCase instances.
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)
Given a method of a TestCase that represents a test, return a TestCase instance for that test.
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 facsimilie 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.
RaisesTypeError if '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, thing, recurse=False): (source)
Given a Python object, return whatever tests that are in it. Whatever 'in' might mean.
ParametersthingA Python object. A module, method, class or package.
recurseWhether or not to look in subpackages of packages. Defaults to False.
ReturnsA TestCase or TestSuite.
def loadByName(self, name, recurse=False): (source)
Given a string representing a Python object, return whatever tests are in that object.

If name is somehow inaccessible (e.g. the module can't be imported, there is no Python object with that name etc) then return an ErrorHolder.

ParametersnameThe fully-qualified name of a Python object.
def loadByNames(self, names, recurse=False): (source)
Construct a TestSuite containing all the tests found in 'names', where names is a list of fully qualified python names and/or filenames. The suite returned will have no duplicate tests, even if the same object is named twice.
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().
API Documentation for Twisted, generated by pydoctor at 2013-11-08 22:07:30.