File: test_issue223.py

package info (click to toggle)
rdflib 6.1.1-1
  • links: PTS, VCS
  • area: main
  • in suites: bookworm
  • size: 38,248 kB
  • sloc: python: 39,216; sh: 153; makefile: 110
file content (24 lines) | stat: -rw-r--r-- 591 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
from rdflib.graph import Graph
from rdflib.term import URIRef
from rdflib.collection import Collection

ttl = """
@prefix : <http://example.org/>.

:s :p (:a :b :a).
"""


def test_collection_with_duplicates():
    g = Graph().parse(data=ttl, format="turtle")
    for _, _, o in g.triples(
        (URIRef("http://example.org/s"), URIRef("http://example.org/p"), None)
    ):
        break
    c = g.collection(o)
    assert list(c) == list(URIRef("http://example.org/" + x) for x in ["a", "b", "a"])
    assert len(c) == 3


if __name__ == "__main__":
    test_collection_with_duplicates()