Skip to content

Commit a88f388

Browse files
committed
fix: use correct is_file method and add more test cases
1 parent 2bc7614 commit a88f388

2 files changed

Lines changed: 14 additions & 2 deletions

File tree

pylode/utils.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -244,7 +244,7 @@ def _get_prop_label(prop_iri: URIRef, back_onts: Graph) -> dict:
244244

245245
def _is_file(filepath: str) -> bool:
246246
try:
247-
if Path(filepath)._is_file():
247+
if Path(filepath).is_file():
248248
return True
249249
return False
250250
except:

tests/test_utils.py

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,8 @@
66
from rdflib.namespace import DCTERMS, OWL, RDF, RDFS, XSD
77
import pytest
88

9+
current_dir = Path(__file__).parent
10+
911

1012
# scope="session" so that this is reused without regeneration in this testing session
1113
@pytest.fixture(scope="session")
@@ -172,7 +174,7 @@ def test_prop_obj_pair_html(fix_ont, fix_load_background_onts, fix_get_ns):
172174
assert actual == expected, f"Object HTML '{actual}' != '{expected}'"
173175

174176

175-
def test_load_ontology_file():
177+
def test_load_ontology_data():
176178
data = """
177179
@prefix : <http://www.w3.org/ns/dx/prof/> .
178180
@prefix dc: <http://purl.org/dc/elements/1.1/> .
@@ -189,3 +191,13 @@ def test_load_ontology_file():
189191
"""
190192
graph = load_ontology(data)
191193
assert len(graph)
194+
195+
196+
def test_load_ontology_file():
197+
filepath = current_dir / "prof.ttl"
198+
199+
graph = load_ontology(filepath)
200+
assert len(graph)
201+
202+
graph = load_ontology(str(filepath))
203+
assert len(graph)

0 commit comments

Comments
 (0)