module documentation
(source)

A miscellany of code used to run Trial tests.

Maintainer: Jonathan Lange

Class ​Destructive​Test​Suite A test suite which remove the tests once run, to minimize memory usage.
Class ​Error​Holder No summary
Class ​Logged​Suite Any errors logged in this suite will be reported to the TestResult object.
Class ​Test​Holder Placeholder for a TestCase inside a reporter. As far as a TestResult is concerned, this looks exactly like a unit test.
Class ​Test​Loader I find tests inside function, modules, files -- whatever -- then return them wrapped inside a Test (either a TestSuite or a TestCase).
Class ​Trial​Runner A specialised runner that the trial front end uses.
Class ​Trial​Suite Suite to wrap around every single test in a trial run. Used internally by Trial to set up things necessary for Trial tests to work, regardless of what context they are run in.
Function filename​To​Module Given a filename, do whatever possible to return a module object matching that file.
Function is​Package Given an object return True if the object looks like a package
Function is​Package​Directory Is the directory at path 'dirname' a Python package directory? Returns the name of the __init__ file (it may have a weird extension) if dirname is a package directory. Otherwise, returns False
Function is​Test​Case
Function name
Function samefile A hacky implementation of os.path.samefile. Used by filenameToModule when the platform doesn't provide os.path.samefile. Do not use this.
Constant NOT​_IN​_TEST Undocumented
Variable pyunit Undocumented
Function _get​Method​Name​In​Class Find the attribute name on the method's class which refers to the method.
Function _import​From​File Undocumented
Function _qual​Name​Walker Given a Python qualified name, this function yields a 2-tuple of the most specific qualified name first, followed by the next-most-specific qualified name, and so on, paired with the remainder of the qualified name.
Function _resolve​Directory Undocumented
def filenameToModule(fn): (source)

Given a filename, do whatever possible to return a module object matching that file.

If the file in question is a module in Python path, properly import and return that module. Otherwise, load the source manually.

Parameters
fnA filename.
Returns
A module object.
Raises
ValueErrorIf fn does not exist.
def isPackage(module): (source)
Given an object return True if the object looks like a package
def isPackageDirectory(dirname): (source)
Is the directory at path 'dirname' a Python package directory? Returns the name of the __init__ file (it may have a weird extension) if dirname is a package directory. Otherwise, returns False
def isTestCase(obj): (source)
Returns
True if obj is a class that contains test cases, False otherwise. Used to find all the tests in a module.
def name(thing): (source)
Parameters
thingan object from modules (instance of PythonModule, PythonAttribute), a TestCase subclass, or an instance of a TestCase.
def samefile(filename1, filename2): (source)
A hacky implementation of os.path.samefile. Used by filenameToModule when the platform doesn't provide os.path.samefile. Do not use this.
NOT_IN_TEST: str = (source)

Undocumented

Value
'<not in test>'
pyunit = (source)

Undocumented

def _getMethodNameInClass(method): (source)

Find the attribute name on the method's class which refers to the method.

For some methods, notably decorators which have not had __name__ set correctly:

getattr(method.im_class, method.__name__) != method

def _importFromFile(fn, moduleName=None): (source)

Undocumented

def _qualNameWalker(qualName): (source)
Given a Python qualified name, this function yields a 2-tuple of the most specific qualified name first, followed by the next-most-specific qualified name, and so on, paired with the remainder of the qualified name.
Parameters
qual​Name:strA Python qualified name.
def _resolveDirectory(fn): (source)

Undocumented