pygimli.testing

Testing utilities

In Python you can call pygimli.test(show=True) to run all docstring examples.

Writing tests for pygimli

Please check: https://pytest.org/latest/example/index.html

Overview

Functions

join(a, *p) Join two or more pathname components, inserting ‘/’ as needed.
realpath(filename) Return the canonical path of the specified filename, eliminating any symbolic links encountered in the path.
test([target, show, onlydoctests, coverage, …]) Run docstring examples and additional tests.

Functions

join

pygimli.testing.join(a, *p)[source]

Join two or more pathname components, inserting ‘/’ as needed. If any component is an absolute path, all previous path components will be discarded. An empty last part will result in a path that ends with a separator.

realpath

pygimli.testing.realpath(filename)[source]

Return the canonical path of the specified filename, eliminating any symbolic links encountered in the path.

test

pygimli.testing.test(target=None, show=False, onlydoctests=False, coverage=False, htmlreport=False, abort=False, verbose=True)[source]

Run docstring examples and additional tests.

Parameters:
target : function or string, optional

Function or method to test. By default everything is tested.

show : boolean, optional

Show matplotlib windows during test run. They will be closed automatically.

onlydoctests : boolean, optional

Run test files in ../tests as well.

coverage : boolean, optional

Create a coverage report. Requires the pytest-cov plugin.

htmlreport : str, optional

Filename for HTML report such as www.pygimli.org/build_tests.html. Requires pytest-html plugin.

abort : boolean, optional

Return correct exit code, e.g. abort documentation build when a test fails.

Examples

>>> import pygimli as pg
>>> # You can test everything with pg.test() or test a single function:
>>> pg.test("pg.utils.boxprint", verbose=False)
>>> # The target argument can also be the function directly
>>> from pygimli.utils import boxprint
>>> pg.test(boxprint, verbose=False)


2019 - GIMLi Development Team
Created using Bootstrap, Sphinx and pyGIMLi 1.0.11+38.g7483f4dd on Sep 20, 2019.