Skip to content

Commit

Permalink
rdflib7 compatibility
Browse files Browse the repository at this point in the history
  • Loading branch information
cmungall committed Aug 7, 2023
1 parent bb8e8e8 commit bdbefec
Show file tree
Hide file tree
Showing 6 changed files with 8 additions and 8 deletions.
4 changes: 2 additions & 2 deletions tests/test_base/test_assertions.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ def test_differentindividuals_rdf(self):
<http://example.org/a#Alex> a owl:NamedIndividual ;
owl:differentFrom <http://example.org/a#Bob> .
<http://example.org/a#Bob> a owl:NamedIndividual .""", g.serialize(format="turtle").decode().strip())
<http://example.org/a#Bob> a owl:NamedIndividual .""", g.serialize(format="turtle").strip())

def test_classassertion(self):
self.assertEqual('ClassAssertion( a:GriffinFamilyMember a:Peter_Griffin )',
Expand Down Expand Up @@ -79,7 +79,7 @@ def test_objectpropertyassertion_rdf(self):
ns1:hasBrother a <http://www.w3.org/2002/07/owl#ObjectProperty> .
ns1:Stewie a <http://www.w3.org/2002/07/owl#NamedIndividual> .""", g.serialize(format='turtle').decode())
ns1:Stewie a <http://www.w3.org/2002/07/owl#NamedIndividual> .""", g.serialize(format='turtle'))
if diff:
print(diff)
self.fail()
Expand Down
2 changes: 1 addition & 1 deletion tests/test_issues/test_issue_12.py
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ def test_owlf_sample(self):
clue.to_rdf(g)
g.bind('skos', SKOS)
g.bind('dct', DCTERMS)
owlrdf = g.serialize(format='turtle').decode().strip()
owlrdf = g.serialize(format='turtle').strip()
# print(owlrdf)
self.assertEqual(expected.strip(), owlrdf)

Expand Down
2 changes: 1 addition & 1 deletion tests/test_issues/test_rdflib_cache_issue.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ def test_cache_bug(self):
MYNS:Foo a MYNS:Bar .
YOURNS:SAM YOURNS:SAM YOURNS:SAM .""", g.serialize(format="turtle").decode().strip())
YOURNS:SAM YOURNS:SAM YOURNS:SAM .""", g.serialize(format="turtle").strip())


if __name__ == '__main__':
Expand Down
2 changes: 1 addition & 1 deletion tests/test_owl2_test_suite/all_parser.py
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ def write_conversion(subj: str, txt: Optional[str], fmt: str, dir: str = outputd
g = Graph()
try:
g.parse(data=xml_txt)
write_conversion(subj, g.serialize(format="turtle").decode(), 'ttl')
write_conversion(subj, g.serialize(format="turtle"), 'ttl')
except ParserError as e:
errors[subj] = str(e)
else:
Expand Down
4 changes: 2 additions & 2 deletions tests/test_owl2_test_suite/test_owl2.py
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ def n_rdf(n: Union[BNode, URIRef, Literal]) -> str:
return nstr(n) if isinstance(n, BNode) else n.n3()

# return '\n'.join(sorted([f"{n_rdf(s)} {n_rdf(p)} {n_rdf(o)} ." for s, p, o in list(g)]))
return g.serialize(format="turtle").decode()
return g.serialize(format="turtle")


def validate_owl2(fileloc: str) -> bool:
Expand Down Expand Up @@ -125,7 +125,7 @@ def validate_owl2(fileloc: str) -> bool:
if do_rdf:
roundtrip_rdf = Graph()
ontology_2.to_rdf(roundtrip_rdf)
logging.info('\n========== Round Trip RDF =================\n' + roundtrip_rdf.serialize(format="turtle").decode())
logging.info('\n========== Round Trip RDF =================\n' + roundtrip_rdf.serialize(format="turtle"))

# 5) Make sure that the RDF representation stll matches
# g(f(functional_repr)) == g(f(f**-1(f(functional_repr))
Expand Down
2 changes: 1 addition & 1 deletion tests/utils/rdf_comparator.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ def print_triples(g: Graph) -> None:
Print the contents of g into stdout
:param g: graph to print
"""
g_text = re.sub(r'@prefix.*\n', '', g.serialize(format="turtle").decode())
g_text = re.sub(r'@prefix.*\n', '', g.serialize(format="turtle"))
print(g_text)


Expand Down

0 comments on commit bdbefec

Please sign in to comment.