From bdbefecc1e6e910790e26db8d301f2da59a7da59 Mon Sep 17 00:00:00 2001 From: cmungall Date: Mon, 7 Aug 2023 14:52:45 -0700 Subject: [PATCH] rdflib7 compatibility --- tests/test_base/test_assertions.py | 4 ++-- tests/test_issues/test_issue_12.py | 2 +- tests/test_issues/test_rdflib_cache_issue.py | 2 +- tests/test_owl2_test_suite/all_parser.py | 2 +- tests/test_owl2_test_suite/test_owl2.py | 4 ++-- tests/utils/rdf_comparator.py | 2 +- 6 files changed, 8 insertions(+), 8 deletions(-) diff --git a/tests/test_base/test_assertions.py b/tests/test_base/test_assertions.py index 385bee3..ce31139 100644 --- a/tests/test_base/test_assertions.py +++ b/tests/test_base/test_assertions.py @@ -47,7 +47,7 @@ def test_differentindividuals_rdf(self): a owl:NamedIndividual ; owl:differentFrom . - a owl:NamedIndividual .""", g.serialize(format="turtle").decode().strip()) + a owl:NamedIndividual .""", g.serialize(format="turtle").strip()) def test_classassertion(self): self.assertEqual('ClassAssertion( a:GriffinFamilyMember a:Peter_Griffin )', @@ -79,7 +79,7 @@ def test_objectpropertyassertion_rdf(self): ns1:hasBrother a . -ns1:Stewie a .""", g.serialize(format='turtle').decode()) +ns1:Stewie a .""", g.serialize(format='turtle')) if diff: print(diff) self.fail() diff --git a/tests/test_issues/test_issue_12.py b/tests/test_issues/test_issue_12.py index c853556..9a771d5 100644 --- a/tests/test_issues/test_issue_12.py +++ b/tests/test_issues/test_issue_12.py @@ -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) diff --git a/tests/test_issues/test_rdflib_cache_issue.py b/tests/test_issues/test_rdflib_cache_issue.py index ae5b804..a3971b6 100644 --- a/tests/test_issues/test_rdflib_cache_issue.py +++ b/tests/test_issues/test_rdflib_cache_issue.py @@ -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__': diff --git a/tests/test_owl2_test_suite/all_parser.py b/tests/test_owl2_test_suite/all_parser.py index bdee9f1..d8d11e2 100644 --- a/tests/test_owl2_test_suite/all_parser.py +++ b/tests/test_owl2_test_suite/all_parser.py @@ -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: diff --git a/tests/test_owl2_test_suite/test_owl2.py b/tests/test_owl2_test_suite/test_owl2.py index f14cdd3..7385bfa 100644 --- a/tests/test_owl2_test_suite/test_owl2.py +++ b/tests/test_owl2_test_suite/test_owl2.py @@ -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: @@ -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)) diff --git a/tests/utils/rdf_comparator.py b/tests/utils/rdf_comparator.py index 67aa425..86ffab7 100644 --- a/tests/utils/rdf_comparator.py +++ b/tests/utils/rdf_comparator.py @@ -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)