File: test_dataset_default_serialize_format.py

package info (click to toggle)
rdflib 7.4.0-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 77,852 kB
  • sloc: python: 59,555; sh: 153; makefile: 83; ruby: 74; xml: 45
file content (18 lines) | stat: -rw-r--r-- 605 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
from rdflib import Dataset
from test.data import TEST_DATA_DIR


def test_dataset_default_serialize_format_trig():
    ds = Dataset()
    ds.parse(source=TEST_DATA_DIR / "nquads.rdflib" / "test5.nquads", format="nquads")
    statements_count = len(ds)
    assert statements_count

    # Previously, when the default format is 'turtle', given that the dataset has no
    # statements in the default graph, the output of serialize() was empty.
    output = ds.serialize().strip()
    assert output != ""

    ds2 = Dataset()
    ds2.parse(data=output, format="trig")
    assert len(ds2) == statements_count