-
Notifications
You must be signed in to change notification settings - Fork 564
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'master' into 5.0.0-dev
* master: Revert "Made ClosedNamespace (and _RDFNamespace) inherit from Namespace" Revert "re-introduces special handling for DCTERMS.title and test for it" Read and discard server response for update queries, otherwise the socket will eventually block Remove an unused import sparql select nothing doesn't return a row anymore, fixes #554 test for #554 minor: isinstance instead of type-equals adapted agg_Sample to return None instead of 0 if no binding is found SAMPLE may return None if no binding is found made test_issue563 py26 compatible fixing issue #563
- Loading branch information
Showing
9 changed files
with
102 additions
and
45 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
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
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
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,14 @@ | ||
# test for https://github.com/RDFLib/rdflib/issues/554 | ||
|
||
import rdflib | ||
|
||
def test_sparql_empty_no_row(): | ||
g = rdflib.Graph() | ||
q = 'select ?whatever { }' | ||
r = list(g.query(q)) | ||
assert r == [], \ | ||
'sparql query %s should return empty list but returns %s' % (q, r) | ||
|
||
|
||
if __name__ == '__main__': | ||
test_sparql_empty_no_row() |
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,48 @@ | ||
from rdflib import BNode, Literal, Graph, Namespace | ||
from rdflib.compare import isomorphic | ||
|
||
EX = Namespace("http://example.org/") | ||
QUERY = """ | ||
PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#> | ||
PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#> | ||
SELECT ?x (%s(?y) as ?ys) (%s(?z) as ?zs) WHERE { | ||
VALUES (?x ?y ?z) { | ||
(2 6 UNDEF) | ||
(2 UNDEF 10) | ||
(3 UNDEF 15) | ||
(3 9 UNDEF) | ||
(5 UNDEF 25) | ||
} | ||
} | ||
GROUP BY ?x | ||
""" | ||
|
||
def test_sample(): | ||
g = Graph() | ||
results = set(tuple(i) for i in g.query(QUERY % ("SAMPLE", "SAMPLE"))) | ||
|
||
assert results == set([ | ||
(Literal(2), Literal(6), Literal(10)), | ||
(Literal(3), Literal(9), Literal(15)), | ||
(Literal(5), None, Literal(25)), | ||
]) | ||
|
||
def test_count(): | ||
g = Graph() | ||
results = set(tuple(i) for i in g.query(QUERY % ("COUNT", "COUNT"))) | ||
|
||
assert results == set([ | ||
(Literal(2), Literal(1), Literal(1)), | ||
(Literal(3), Literal(1), Literal(1)), | ||
(Literal(5), Literal(0), Literal(1)), | ||
]) | ||
|
||
if __name__ == "__main__": | ||
test_sample() | ||
test_count() | ||
|
||
|
||
|
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