Home | Trees | Indices | Help |
|
---|
|
Module tests are extremely important to keep the Biskit package
manageable and functional. Every Biskit module should contain a class
derrived from BiskitTest (conventionally called Test
)
that comprises one or more test functions. BiskitTestLoader then automatically extracts all
BiskitTest child classes from the whole package and bundles them into a
FilteredTestSuite.
Test cases that are LONG, depend on PVM or external programs (EXE) or are obsolete (OLD) should be marked with the appropriate tag(s) by overriding BiskitTest.TAGS on the class level. Test cases can then be filtered out or included into the FilteredTestSuite according to their TAGS.
Originally, testing code was simply in the __main__ section of each module where we could execute it directly from emacs (or with python -i) for interactive debugging. By comparison, unittest test fixtures are less easy to execute stand-alone and intermediate variables remain hidden within the test instance. The localTest() removes this hurdle and runs the test code of a single module as if it would be executed directly in __main__. Simply putting the localTest() function without parameters into the __main__ section of your module is enough. Test.test_* methods should assign intermediate and final results to self.|something| variables -- localTest will then push all self.* fields into the global namespace for interactive debugging.class MyClass: ... ### Module testing ### import Biskit.test as BT class Test(BT.BiskitTest): """Test MyModule""" TAGS = [ BT.LONG ] def test_veryLongComputation( self ): """MyModule.veryLongComputation test""" self.m = MyClass() self.result = self.m.veryLongComputation() if self.local: ## only if the module is executed directly print self.result self.assertEqual( self.result, 42, 'unexpected result' ) if __name__ == '__main__': ## run Test and push self.* fields into global namespace BT.localTest( ) print result ## works thanks to some namespace magic in localTestNote:
test
.
|
|||
| BiskitTestError | ||
|
BiskitTest Base class for Biskit test cases. |
||
|
FilteredTestSuite Collection of BiskitTests filtered by category tags. |
||
|
Flushing_TextTestResult Helper class for (Flushing)TextTestRunner. |
||
|
FlushingTextTestRunner Convince TextTestRunner to use the flushing text output rather than the default one. |
||
|
BiskitTestLoader A replacement for the unittest TestLoaders. |
||
|
Test Mock test, test doesn't test itself |
|
|||
dict
|
getOuterNamespace() Fetch the namespace of the module/script running as __main__. |
||
[ class ]
|
extractTestCases(namespace) Returns all BisktTest child classes found in given namespace |
||
unittest.TestResult
|
localTest(testclass=None,
verbosity=BiskitTest.VERBOSITY,
debug=BiskitTest.DEBUG,
log=BiskitTest.TESTLOG) Perform the BiskitTest(s) found in the scope of the calling module. |
||
| _use(defaults) | ||
|
_str2tags(s) convert list of string options to list of valid TAGS |
||
| _convertOptions(o) |
|
|||
|
NORMAL = 0
|
||
|
LONG = 1
|
||
|
PVM = 2
|
||
|
EXE = 3
|
||
|
OLD = 5
|
||
|
defaults = {'i': '', 'e': 'old', 'p': ['Biskit', 'Biskit.Dock',...
|
||
|
o = T.cmdDict(defaults)
|
||
|
l = BiskitTestLoader(allowed= o ['i'], forbidden= o ['e'...
|
|
Fetch the namespace of the module/script running as __main__.
|
|
Perform the BiskitTest(s) found in the scope of the calling module. After the test run, all fields of the BiskitTest instance are pushed into the global namespace so that they can be inspected in the interactive interpreter. The BiskitTest instance itself is also put into the calling namespace as variable 'self', so that test code fragments referring to it can be executed interactively.
|
|
convert list of string options to list of valid TAGS |
|
|
NORMAL
|
LONG
|
PVM
|
EXE
|
OLD
|
defaults
|
o
|
l
|
Home | Trees | Indices | Help |
|
---|
Generated by Epydoc 3.0alpha3 on Tue May 1 22:34:50 2007 | http://epydoc.sourceforge.net |