diff --git a/test/data/variants/diverse_quads-asserts.json b/test/data/variants/diverse_quads-asserts.json new file mode 100644 index 000000000..6fd30354e --- /dev/null +++ b/test/data/variants/diverse_quads-asserts.json @@ -0,0 +1,4 @@ +{ + "quad_count": 10, + "exact_match": true +} diff --git a/test/data/variants/diverse_quads.jsonld b/test/data/variants/diverse_quads.jsonld new file mode 100644 index 000000000..a3e8b7411 --- /dev/null +++ b/test/data/variants/diverse_quads.jsonld @@ -0,0 +1,73 @@ +{ + "@graph": [ + { + "@graph": [ + { + "@id": "egschema:subject", + "egschema:predicate": [ + 12, + { + "@id": "egschema:object" + } + ] + }, + { + "@id": "eghttp:subject", + "predicate": { + "@language": "jpx", + "@value": "日本語の表記体系" + } + }, + { + "@id": "egurn:subject", + "egschema:predicate": { + "@id": "egschema:subject" + } + } + ], + "@id": "egschema:graph" + }, + { + "@id": "egschema:subject", + "egschema:predicate": { + "@id": "egschema:object" + } + }, + { + "@id": "eghttp:subject", + "predicate": "typeless" + }, + { + "@graph": [ + { + "@id": "egschema:subject", + "egschema:predicate": { + "@id": "egschema:object" + }, + "predicate": [ + "XSD string", + { + "@id": "eghttp:object" + } + ] + } + ], + "@id": "egurn:graph" + }, + { + "@id": "egurn:subject", + "egurn:predicate": { + "@id": "egurn:object" + } + } + ], + "@context": { + "predicate": { + "@id": "http://example.com/predicate" + }, + "egurn": "urn:example:", + "xsd": "http://www.w3.org/2001/XMLSchema#", + "egschema": "example:", + "eghttp": "http://example.com/" + } +} diff --git a/test/data/variants/diverse_quads.nq b/test/data/variants/diverse_quads.nq new file mode 100644 index 000000000..0351d0485 --- /dev/null +++ b/test/data/variants/diverse_quads.nq @@ -0,0 +1,10 @@ + "日本語の表記体系"@jpx . + . + . + "12"^^ . + . + . + "XSD string" . + . + "typeless" . + . diff --git a/test/data/variants/diverse_quads.trig b/test/data/variants/diverse_quads.trig new file mode 100644 index 000000000..9d3427868 --- /dev/null +++ b/test/data/variants/diverse_quads.trig @@ -0,0 +1,27 @@ +@prefix egschema: . +@prefix eghttp: . +@prefix egurn: . +@prefix xsd: . + +egschema:graph { + eghttp:subject eghttp:predicate "日本語の表記体系"@jpx . + + egurn:subject egschema:predicate egschema:subject . + + egschema:subject egschema:predicate egschema:object, + 12 . +} + +egurn:graph { + egschema:subject egschema:predicate egschema:object ; + eghttp:predicate eghttp:object, + "XSD string"^^xsd:string . +} + +{ + egschema:subject egschema:predicate egschema:object . + + eghttp:subject eghttp:predicate "typeless" . + + egurn:subject egurn:predicate egurn:object . +} diff --git a/test/data/variants/diverse_triples-asserts.json b/test/data/variants/diverse_triples-asserts.json new file mode 100644 index 000000000..a4cab08ae --- /dev/null +++ b/test/data/variants/diverse_triples-asserts.json @@ -0,0 +1,4 @@ +{ + "quad_count": 5, + "exact_match": true +} diff --git a/test/data/variants/diverse_triples.hext b/test/data/variants/diverse_triples.hext new file mode 100644 index 000000000..9baf53f71 --- /dev/null +++ b/test/data/variants/diverse_triples.hext @@ -0,0 +1,5 @@ +["urn:example:subject", "example:predicate", "example:subject", "globalId", "", ""] +["example:subject", "example:predicate", "example:object", "globalId", "", ""] +["example:object", "http://example.com/predicate", "XSD string", "http://www.w3.org/2001/XMLSchema#string", "", ""] +["http://example.com/subject", "http://example.com/predicate", "日本語の表記体系", "http://www.w3.org/1999/02/22-rdf-syntax-ns#langString", "jpx", ""] +["example:subject", "example:predicate", "12", "http://www.w3.org/2001/XMLSchema#integer", "", ""] diff --git a/test/data/variants/diverse_triples.jsonld b/test/data/variants/diverse_triples.jsonld new file mode 100644 index 000000000..a0e947cfa --- /dev/null +++ b/test/data/variants/diverse_triples.jsonld @@ -0,0 +1,40 @@ +{ + "@graph": [ + { + "@id": "egschema:object", + "eghttp:predicate": "XSD string" + }, + { + "@id": "egschema:subject", + "egschema:predicate": [ + 12, + { + "@id": "egschema:object" + } + ] + }, + { + "@id": "eghttp:subject", + "eghttp:predicate": { + "@language": "jpx", + "@value": "日本語の表記体系" + } + }, + { + "@id": "egurn:subject", + "egschema:predicate": { + "@id": "egschema:subject" + } + } + ], + "@context": { + "predicate": { + "@id": "example:predicate", + "@type": "http://www.w3.org/2001/XMLSchema#integer" + }, + "egurn": "urn:example:", + "xsd": "http://www.w3.org/2001/XMLSchema#", + "egschema": "example:", + "eghttp": "http://example.com/" + } +} diff --git a/test/data/variants/diverse_triples.nt b/test/data/variants/diverse_triples.nt new file mode 100644 index 000000000..3b1129077 --- /dev/null +++ b/test/data/variants/diverse_triples.nt @@ -0,0 +1,5 @@ + "日本語の表記体系"@jpx . + . + "XSD string" . + . + "12"^^ . diff --git a/test/data/variants/diverse_triples.ttl b/test/data/variants/diverse_triples.ttl new file mode 100644 index 000000000..2fcfb3a37 --- /dev/null +++ b/test/data/variants/diverse_triples.ttl @@ -0,0 +1,13 @@ +@prefix eghttp: . +@prefix egurn: . +@prefix egschema: . +@prefix xsd: . + +eghttp:subject eghttp:predicate "日本語の表記体系"@jpx . + +egurn:subject egschema:predicate egschema:subject . + +egschema:object eghttp:predicate "XSD string"^^xsd:string . + +egschema:subject egschema:predicate egschema:object, + 12 . diff --git a/test/data/variants/more_quads-asserts.json b/test/data/variants/more_quads-asserts.json new file mode 100644 index 000000000..83ae1a8af --- /dev/null +++ b/test/data/variants/more_quads-asserts.json @@ -0,0 +1,4 @@ +{ + "quad_count": 6, + "exact_match": true +} diff --git a/test/data/variants/more_quads.jsonld b/test/data/variants/more_quads.jsonld new file mode 100644 index 000000000..08d6c9360 --- /dev/null +++ b/test/data/variants/more_quads.jsonld @@ -0,0 +1,56 @@ +{ + "@graph": [ + { + "@graph": [ + { + "@id": "example:s20", + "example:p20": { + "@id": "example:o20" + } + }, + { + "@id": "example:s21", + "example:p21": { + "@id": "example:o21" + } + } + ], + "@id": "example:g2" + }, + { + "@id": "example:s00", + "p00": "example:o02" + }, + { + "@id": "example:s01", + "p01": "example:o01" + }, + { + "@id": "example:s10", + "p10": "example:o10" + }, + { + "@id": "example:s11", + "p11": "example:o11" + } + ], + "@context": { + "p10": { + "@id": "http://example.org/p10", + "@type": "@id" + }, + "p01": { + "@id": "http://example.org/p01", + "@type": "@id" + }, + "p00": { + "@id": "http://example.org/p00", + "@type": "@id" + }, + "p11": { + "@id": "http://example.org/p11", + "@type": "@id" + }, + "example": "http://example.org/" + } +} diff --git a/test/data/variants/more_quads.nq b/test/data/variants/more_quads.nq new file mode 100644 index 000000000..64b6ccf33 --- /dev/null +++ b/test/data/variants/more_quads.nq @@ -0,0 +1,6 @@ + . + . + . + . + . + . diff --git a/test/data/variants/more_quads.trig b/test/data/variants/more_quads.trig new file mode 100644 index 000000000..ddbf7020e --- /dev/null +++ b/test/data/variants/more_quads.trig @@ -0,0 +1,15 @@ +@prefix example: . + +example:s00 example:p00 example:o02 . +example:s01 example:p01 example:o01 . + + +{ + example:s10 example:p10 example:o10 . + example:s11 example:p11 example:o11 . +} + +example:g2 { + example:s20 example:p20 example:o20 . + example:s21 example:p21 example:o21 . +} diff --git a/test/test_graph/test_variants.py b/test/test_graph/test_variants.py index be78342fb..8a68e2856 100644 --- a/test/test_graph/test_variants.py +++ b/test/test_graph/test_variants.py @@ -2,6 +2,7 @@ import logging import os import re +import sys from dataclasses import dataclass, field from pathlib import Path, PurePath from test.data import TEST_DATA_DIR @@ -165,8 +166,30 @@ def for_directory( """, raises=AssertionError, ), + ("variants/diverse_quads"): pytest.mark.xfail( + reason=""" + TriG parsing gets confused about what graph 'XSD string' appears in: + (rdflib.term.URIRef('example:subject'), + rdflib.term.URIRef('http://example.com/predicate'), + rdflib.term.Literal('XSD string'), + - rdflib.term.URIRef('example:graph')), + + rdflib.term.URIRef('urn:example:graph')), + ? ++++ + """, + raises=AssertionError, + ), } +if sys.platform == "win32": + EXPECTED_FAILURES["variants/diverse_triples"] = pytest.mark.xfail( + reason=""" + Some encoding issue when parsing hext on windows: + > return codecs.charmap_decode(input,self.errors,decoding_table)[0] + E UnicodeDecodeError: 'charmap' codec can't decode byte 0x81 in position 356: character maps to + """, + raises=UnicodeDecodeError, + ) + def tests_found() -> None: logging.debug("VARIANTS_DIR = %s", VARIANTS_DIR) diff --git a/test/test_roundtrip.py b/test/test_roundtrip.py index 00ad81571..98c303234 100644 --- a/test/test_roundtrip.py +++ b/test/test_roundtrip.py @@ -164,6 +164,26 @@ """, raises=AssertionError, ), + ("json-ld", "diverse_quads.trig"): pytest.mark.xfail( + reason=""" + jsonld serializer is dropping datatype: + only in first: + (rdflib.term.URIRef('example:subject'), rdflib.term.URIRef('http://example.com/predicate'), rdflib.term.Literal('XSD string', datatype=rdflib.term.URIRef('http://www.w3.org/2001/XMLSchema#string'))) + only in second: + (rdflib.term.URIRef('example:subject'), rdflib.term.URIRef('http://example.com/predicate'), rdflib.term.Literal('XSD string')) + """, + raises=AssertionError, + ), + ("hext", "diverse_quads.trig"): pytest.mark.xfail( + reason=""" + hext serializer is dropping datatype: + only in first: + (rdflib.term.URIRef('example:subject'), rdflib.term.URIRef('http://example.com/predicate'), rdflib.term.Literal('XSD string', datatype=rdflib.term.URIRef('http://www.w3.org/2001/XMLSchema#string'))) + only in second: + (rdflib.term.URIRef('example:subject'), rdflib.term.URIRef('http://example.com/predicate'), rdflib.term.Literal('XSD string')) + """, + raises=AssertionError, + ), } # This is for files which can only be represented properly in one format @@ -291,6 +311,9 @@ def test_n3(checker: Callable[[str, str, Path], None], args: Tuple[str, str, Pat (TEST_DATA_DIR / "variants" / "rdf_prefix.jsonld", "json-ld"), (TEST_DATA_DIR / "variants" / "simple_quad.trig", "trig"), (TEST_DATA_DIR / "variants" / "rdf11trig_eg2.trig", "trig"), + (TEST_DATA_DIR / "variants" / "diverse_triples.nt", "ntriples"), + (TEST_DATA_DIR / "variants" / "diverse_quads.nq", "nquads"), + (TEST_DATA_DIR / "variants" / "diverse_quads.trig", "trig"), (TEST_DATA_DIR / "example-lots_of_graphs.n3", "n3"), (TEST_DATA_DIR / "issue156.n3", "n3"), ]