Adpated from http://wiki.cython.org/FAQ#HowcanIrundoctestsinCythoncode.28pyxfiles.29.3F Use the testmod function from test_support, don’t use this directly. ====================================================================
Cython-compatible wrapper for doctest.testmod().
Usage example, assuming a Cython module mymod.pyx is compiled. This is run from the command line, passing a command to Python: python -c “import cydoctest, mymod; cydoctest.testmod(mymod)”
(This still won’t let a Cython module run its own doctests when called with “python mymod.py”, but it’s pretty close. Further options can be passed to testmod() as desired, e.g. verbose=True.)
Bases: doctest.DocTestFinder
Extract docstrings from cython functions, that would be skipped by doctest otherwise.
Return true if the given object is defined in the given module.
Fix a Cython module’s doctests, then call doctest.testmod()
Bases: numba.testing.runner.Filter
Bases: numba.testing.runner.Filter
Bases: numba.testing.runner.Filter
Bases: object
Test runner used by runtests.py
Call the predicate with a file path (e.g. numba/test/foo.py)
Call the predicate with a dotted name (e.g. numba.tests.foo)
Run tests:
Bases: unittest.case.TestCase
Defines a numba function, that, when called, specializes on the input types. Uses the AST translator backend. For the bytecode translator, use @autojit.
Bases: object
Rewrite docs for python 3
@parametrize(‘foo’, ‘bar’) def test_func(foo_or_bar):
print foo_or_bar # prints ‘foo’ or ‘bar’
Generates a unittest TestCase in the function’s global scope named ‘test_func_testcase’ with parametrized test methods.
‘:return: The original function
Tests a doctest modules with numba functions. When run in nosetests, only populates module.__test__, when run as main, runs the doctests.
Doctest support exposed to numba users.
Tests a doctest modules with numba functions. When run in nosetests, only populates module.__test__, when run as main, runs the doctests.
module: the module to run the doctests in run: whether to run the doctests or just build a __test__ dict verbosity: verbosity level passed to unittest.TextTestRunner
The defualt is 2
optionflags: doctest options (e.g. doctest.ELLIPSIS)