core.collector¶
Support for collecting tests from various sources.
Module Members¶
General Members
Old context stuff
Classes¶
-
class
core.collector.CSPackage(name, parent, pathDir)¶ A class that emulates some Python module behaviour.
This is used to
-
class
core.collector.TesterContext(package)¶ Contextual information for one or more test scripts.
-
core.collector.dirPath The directory path for this contect. There is only one TesterContext for a given directory.
-
core.collector.packageName The name of the (emulated) package for all the tests within this context.
-
class
core.collector.Loader¶ Support for loading test script modules in a controlled environment.
This is a helper for the
Collectorclass. The principle method isloadModule(), which is (biscuit) used to perform the actual importing of a test script. While the test script is being imported, a Python import hook is in place.-
cleanUp() Drop any modules imported by this loader.
This is only to be used when testing this module.
-
loadModule(path) Load a test script as a module within a CSPackage.
If there is no
CSPackagefor the module’s directory then one is created. Then the module is loaded as module of theCSPackage.Return Value
A tuple of(module, errString). Ifmoduleis `` None`` then eithererrStringwill describe the error or will beNoneto indicate thatUnsupportedwas raised.Arguments
- path
- The path to the file that should be imported.
-
wrapImport(func) Decorator: Hook __import__ before invoking the function.
The current __import__ is saved and replaced with
_hookedImport(). Then the decorated function is invoked. The original __import__ is restored once the decorated function returns.
-
-
class
core.collector.Collector(loader=None)¶ Helper to perform the collection of tests.
This can collect the test from a single module or a complete test tree.
-
collect(path, parent=None, namespace=None) Collect all tests and suites for the given python file.
The path should be relative to the current working directory. If it is called “all_tests.py” then all python files and sub-directories will be scanned for tests.
-
collectClassSuite(suite, parent) Collect all tests the given suite instance.
-
collectDir(dirPath, parent) Collect all module suites for the given directory.
The dirPath should be relative to the current working directory.
-
collectModule(modPath, parent, namespace=None) Collect all tests and suites for the given python file.
The path should be relative to the current working directory.
-