forked from RDFLib/rdflib
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
b9a92fd
commit 9a0feed
Showing
2 changed files
with
56 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
from rdflib import Graph | ||
from rdflib.term import BNode, URIRef, rdflib_skolem_genid | ||
|
||
|
||
def test(): | ||
"""Test skolemised URI query retrieves expected results. | ||
Issue: https://github.com/RDFLib/rdflib/issues/1808 | ||
""" | ||
|
||
g = Graph() | ||
g.parse(data='[] <urn:prop> "val" .', format="turtle") | ||
for s, p, o in g: | ||
assert isinstance(s, BNode) | ||
|
||
gs = g.skolemize() | ||
for s, p, o in gs: | ||
assert isinstance(s, URIRef) and s.__contains__(rdflib_skolem_genid) | ||
|
||
query_with_iri = 'select ?p ?o {{ <{}> ?p ?o }}'.format(s) | ||
query_for_all = 'select ?s ?p ?o { ?s ?p ?o }' | ||
|
||
count = 0 | ||
for row in gs.query(query_with_iri): | ||
count += 1 | ||
assert count == 1 | ||
|
||
count = 0 | ||
for row in gs.query(query_for_all): | ||
count += 1 | ||
assert count == 1 | ||
|
||
gp = Graph() | ||
gp.parse(data=gs.serialize(format='turtle'), format='turtle') | ||
|
||
count = 0 | ||
for row in gp.query(query_with_iri): | ||
count += 1 | ||
assert count == 1 | ||
|
||
count = 0 | ||
for row in gp.query(query_for_all): | ||
count += 1 | ||
assert count == 1 |