File: test_issue893.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 (39 lines) | stat: -rw-r--r-- 1,163 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
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
import pickle
from rdflib.graph import Dataset
from rdflib.namespace import Namespace


def test_issue893_ds_unpickle():
    example = Namespace("http://example.com#")

    ds1 = Dataset()
    one = ds1.graph(example.one)

    one.add((example.dan, example.knows, example.lisa))
    one.add((example.lisa, example.knows, example.dan))

    two = ds1.graph(example.two)

    two.add((example.ben, example.knows, example.lisa))
    two.add((example.lisa, example.knows, example.ben))

    assert set(ds1.quads((None, None, None, None))) == set(
        ds1.quads((None, None, None, None))
    )

    picklestring = pickle.dumps(ds1)
    ds2 = pickle.loads(picklestring)

    ds1graphs = list(ds1.graphs())
    ds2graphs = list(ds2.graphs())

    ds1graphs.sort()
    ds2graphs.sort()

    for new_graph, graph in zip(ds2graphs, ds1graphs):
        assert new_graph.identifier == graph.identifier
        for new_triple, triple in zip(
            new_graph.triples((None, None, None)), graph.triples((None, None, None))
        ):
            assert new_triple in graph.triples((None, None, None))
            assert triple in new_graph.triples((None, None, None))