From 9397f13e4ad12feed8e68e2879b8bfcfb8c032bf Mon Sep 17 00:00:00 2001 From: Alex Nelson Date: Thu, 4 May 2023 09:32:36 -0400 Subject: [PATCH] Enable doctests on modules This patch enables review of Python code inlined in the `case-utils` modules' docstrings. An initial docstring test is also included, because `pytest` reports an error if it is called and no tests are found. References: * https://docs.pytest.org/en/7.1.x/how-to/doctest.html Signed-off-by: Alex Nelson --- case_utils/ontology/src/ontology_and_version_iris.py | 5 +++++ tests/Makefile | 5 +++++ 2 files changed, 10 insertions(+) diff --git a/case_utils/ontology/src/ontology_and_version_iris.py b/case_utils/ontology/src/ontology_and_version_iris.py index 7ac429d..e85f0ff 100644 --- a/case_utils/ontology/src/ontology_and_version_iris.py +++ b/case_utils/ontology/src/ontology_and_version_iris.py @@ -29,6 +29,11 @@ def concept_is_cdo_concept(n_concept: rdflib.URIRef) -> bool: """ This function is purposefully distinct from the function used in case_validate. Within this script, the publishing history of CASE and UCO is reviewed. + + >>> concept_is_cdo_concept(rdflib.URIRef("http://example.org/ontology/Thing")) + False + >>> concept_is_cdo_concept(rdflib.URIRef("https://ontology.unifiedcyberontology.org/uco/core/UcoThing")) + True """ concept_iri = str(n_concept) return ( diff --git a/tests/Makefile b/tests/Makefile index c1c626e..f38243d 100644 --- a/tests/Makefile +++ b/tests/Makefile @@ -59,6 +59,11 @@ check: \ check-mypy \ check-isomorphic_diff \ check-case_utils + source venv/bin/activate \ + && pytest \ + --doctest-modules \ + --log-level=DEBUG \ + $(top_srcdir)/case_utils source venv/bin/activate \ && pytest \ --ignore case_utils \