summaryrefslogtreecommitdiff
path: root/test/test_graph_items.py
blob: bc13c367bb5c06d5595a432a505fcfc737f7a92d (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
from rdflib import Graph, RDF


def test_recursive_list_detection():
    g = Graph().parse(
        data="""
        @prefix : <http://www.w3.org/1999/02/22-rdf-syntax-ns#> .

        <> :value _:a .
        _:a :first "turtles"; :rest _:a .

        <> :value [ :first "turtles"; :rest _:b ] .
        _:b :first "all the way down"; :rest _:b .

        <> :value [ :first "turtles"; :rest _:c ] .
        _:c :first "all the way down"; :rest _:a .

        """,
        format="turtle",
    )

    for v in g.objects(None, RDF.value):
        try:
            list(g.items(v))
        except ValueError as e:
            pass
        else:
            assert False, "Expected detection of recursive rdf:rest reference"