def test_roundtrip(): d = Dataset() d.parse(Path(__file__).parent / "test_parser_hext_multigraph.ndjson", format="hext", publicID=d.default_context.identifier) d.default_union = True with open(str( Path(__file__).parent / "test_parser_hext_multigraph.ndjson")) as i: ordered_input = "".join(sorted(i.readlines())).strip() ordered_output = "\n".join(sorted( d.serialize(format="hext").split("\n"))).strip() assert ordered_output == ordered_input
# Query the union of all graphs in the dataset for all triples # we should get Nothing: """ """ # A Dataset's default union graph does not exist by default (default_union property is False) print("Attempt #1 to print all triples in the Dataset:") print("---") for triple in d.triples((None, None, None, None)): print(triple) print("---") print() print() # Set the Dataset's default_union property to True and re-query d.default_union = True print("Attempt #2 to print all triples in the Dataset:") print("---") for triple in d.triples((None, None, None, None)): print(triple) print("---") print() print() # # Remove # # Remove Graph graph_1 from the Dataset d.remove_graph(graph_1)