Skip to content

testutils

Module primarly intended to be imported by tests.

It defines some directories and some utility functions that can be used with and without conftest.

get_tool_module(name)

Imports and returns the module for the EMMOntoPy tool corresponding to name.

Source code in ontopy/testutils.py
def get_tool_module(name):
    """Imports and returns the module for the EMMOntoPy tool
    corresponding to `name`."""
    if str(toolsdir) not in sys.path:
        sys.path.append(str(toolsdir))

    # For Python 3.4+
    spec = spec_from_loader(name, SourceFileLoader(name, str(toolsdir / name)))
    module = module_from_spec(spec)
    spec.loader.exec_module(module)
    return module