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_testonto()
¶
Returns test ontology.
Source code in ontopy/testutils.py
def get_testonto():
"""Returns test ontology."""
return get_ontology(ontodir / "testonto.ttl").load()
get_testutils_emmo(squashed=True)
¶
Returns emmo ontology from test directory.
Source code in ontopy/testutils.py
def get_testutils_emmo(squashed=True):
"""Returns emmo ontology from test directory."""
if squashed:
return get_ontology(ontodir / "emmo.ttl").load()
return get_ontology(ontodir / "emmo" / "emmo.ttl").load()
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