diff --git a/.github/workflows/ci_workflow.yml b/.github/workflows/ci_workflow.yml index d2d20dc69..92a4a54ec 100644 --- a/.github/workflows/ci_workflow.yml +++ b/.github/workflows/ci_workflow.yml @@ -88,7 +88,7 @@ jobs: pip install -U -e .[dev] - name: Test - run: pytest -vvv --cov=ontopy --cov=emmopy --cov-report=xml --cov-report=term + run: pytest -vvv --cov=ontopy --cov=emmopy --cov-report=xml --cov-report=term --doctest-modules - name: Upload coverage to Codecov if: matrix.python-version == '3.7' && github.repository == 'emmo-repo/EMMOntoPy' diff --git a/examples/ontology-from-excel/make_microstructure_onto.py b/examples/ontology-from-excel/make_microstructure_onto.py index de0171fe5..9e29fe073 100755 --- a/examples/ontology-from-excel/make_microstructure_onto.py +++ b/examples/ontology-from-excel/make_microstructure_onto.py @@ -1,11 +1,15 @@ """ python example for creating ontology from excel """ +from pathlib import Path + from ontopy.excelparser import create_ontology_from_excel from ontopy.utils import write_catalog + +thisdir = Path(__file__).resolve().parent ontology, catalog, errdict = create_ontology_from_excel( - "tool/microstructure.xlsx" + thisdir / "tool/microstructure.xlsx" ) ontology.save("microstructure_ontology.ttl", format="turtle", overwrite=True) diff --git a/ontopy/manchester.py b/ontopy/manchester.py index 4f7fdc6e9..143196f76 100644 --- a/ontopy/manchester.py +++ b/ontopy/manchester.py @@ -94,7 +94,7 @@ def evaluate(ontology: owlready2.Ontology, expr: str) -> owlready2.Construct: Example: >>> from ontopy.manchester import evaluate >>> from ontopy import get_ontology - >>> emmo = get_ontology.load() + >>> emmo = get_ontology().load() >>> restriction = evaluate(emmo, 'hasPart some Atom') >>> cls = evaluate(emmo, 'Atom') diff --git a/ontopy/patch.py b/ontopy/patch.py index 14b467619..05235d9e3 100644 --- a/ontopy/patch.py +++ b/ontopy/patch.py @@ -94,7 +94,7 @@ def _setitem(self, name, value): >>> emmo = get_emmo() >>> emmo.Atom['altLabel'] ['ChemicalElement'] - emmo.Atom['altLabel'] = 'Element' + >>> emmo.Atom['altLabel'] = 'Element' >>> emmo.Atom['altLabel'] ['ChemicalElement', 'Element'] diff --git a/pyproject.toml b/pyproject.toml index 8fc9f738c..2a6e73374 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -10,3 +10,6 @@ disable = [ [tool.pylint.format] max-line-length = "80" + +[tool.pytest.ini_options] +addopts = "--doctest-modules --ignore=demo --ignore=docs/demo --ignore=examples --ignore=docs/examples --ignore=site" diff --git a/tests/ontopy_tests/test_graph.py b/tests/ontopy_tests/test_graph.py index 0be76f9ec..afd9747a9 100644 --- a/tests/ontopy_tests/test_graph.py +++ b/tests/ontopy_tests/test_graph.py @@ -7,6 +7,9 @@ from ontopy.ontology import Ontology +@pytest.mark.filterwarnings( + "ignore:Style not defined for relation hasSpecialRelation:UserWarning" +) def test_graph(testonto: "Ontology", tmpdir: "Path") -> None: """Testing OntoGraph on a small ontology diff --git a/tests/test_basic.py b/tests/test_basic.py index e78846b39..148232338 100755 --- a/tests/test_basic.py +++ b/tests/test_basic.py @@ -7,6 +7,7 @@ from ontopy.ontology import Ontology +@pytest.mark.filterwarnings("ignore:adding new IRI to ontology:UserWarning") def test_basic(emmo: "Ontology") -> None: from ontopy import get_ontology from ontopy.utils import LabelDefinitionError, EntityClassDefinitionError diff --git a/tests/test_excelparser/test_excelparser.py b/tests/test_excelparser/test_excelparser.py index 9ae141e34..81448c9a2 100644 --- a/tests/test_excelparser/test_excelparser.py +++ b/tests/test_excelparser/test_excelparser.py @@ -1,7 +1,8 @@ """Test the Excel parser module.""" -import pytest from typing import TYPE_CHECKING +import pytest + from ontopy import get_ontology from ontopy.excelparser import create_ontology_from_excel from ontopy.utils import NoSuchLabelError @@ -10,6 +11,11 @@ from pathlib import Path +@pytest.mark.filterwarnings("ignore:Ignoring concept :UserWarning") +@pytest.mark.filterwarnings("ignore:Invalid parents for :UserWarning") +@pytest.mark.filterwarnings( + "ignore:Not able to add the following concepts :UserWarning" +) def test_excelparser(repo_dir: "Path") -> None: """Basic test for creating an ontology from an Excel file.""" ontopath = ( diff --git a/tests/tools/test_excel2onto.py b/tests/tools/test_excel2onto.py index 6c8859c9b..cd81bf325 100644 --- a/tests/tools/test_excel2onto.py +++ b/tests/tools/test_excel2onto.py @@ -1,12 +1,15 @@ """Test the `ontograph` tool.""" from typing import TYPE_CHECKING +import pytest + if TYPE_CHECKING: from pathlib import Path from types import ModuleType from typing import Callable +@pytest.mark.filterwarnings("ignore::UserWarning") def test_run(get_tool: "Callable[[str], ModuleType]", tmpdir: "Path") -> None: """Check that running `excel2onto` works.