Skip to content

Commit 16bd845

Browse files
test: Add test for Graph.items (RDFLib#2819)
Co-authored-by: Ashley Sommer <[email protected]>
1 parent 7b0e794 commit 16bd845

File tree

1 file changed

+37
-1
lines changed

1 file changed

+37
-1
lines changed

test/test_graph/test_graph_items.py

Lines changed: 37 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,40 @@
1-
from rdflib import RDF, Graph
1+
from rdflib import RDF, Graph, Namespace
2+
3+
EX = Namespace("http://example.org/")
4+
5+
6+
def test_items():
7+
g = Graph().parse(
8+
data="""
9+
@prefix : <http://www.w3.org/1999/02/22-rdf-syntax-ns#> .
10+
11+
<> :value (
12+
<http://example.org/thing1>
13+
<http://example.org/thing2>
14+
).
15+
16+
<> :value (
17+
<http://example.org/thing3>
18+
).
19+
20+
<> :value ().
21+
22+
<> :value (
23+
<http://example.org/thing4>
24+
<http://example.org/thing5>
25+
<http://example.org/thing6>
26+
).
27+
""",
28+
format="turtle",
29+
)
30+
31+
values = {tuple(g.items(v)) for v in g.objects(None, RDF.value)}
32+
assert values == {
33+
(EX.thing1, EX.thing2),
34+
(EX.thing3,),
35+
(),
36+
(EX.thing4, EX.thing5, EX.thing6),
37+
}
238

339

440
def test_recursive_list_detection():

0 commit comments

Comments
 (0)