summaryrefslogtreecommitdiff
path: root/test/test_turtle_sort_issue613.py
blob: 89857b4673ebbe82233b4cb3924a56905ba29f73 (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
29
30
31
32
33
34
35
36
37
import rdflib

"""
In py3, some objects are not comparable. When the turtle serializer tries to sort them everything breaks.

* Timezone aware datetime objects and "naive" datetime objects are not comparable

https://github.com/RDFLib/rdflib/issues/648
https://github.com/RDFLib/rdflib/issues/613

* DocumentFragment
https://github.com/RDFLib/rdflib/issues/676

"""


def test_sort_dates():
    g = rdflib.Graph()
    y = """@prefix ex: <http://ex.org> .
ex:X ex:p "2016-01-01T00:00:00"^^<http://www.w3.org/2001/XMLSchema#dateTime>, "2016-01-01T00:00:00Z"^^<http://www.w3.org/2001/XMLSchema#dateTime> . """

    p = g.parse(data=y, format="turtle")
    p.serialize(format="turtle")


def test_sort_docfrag():
    g = rdflib.Graph()
    y = """@prefix ex: <http://ex.org> .
@prefix rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#> .
ex:X ex:p "<h1>hi</h1>"^^rdf:HTML, "<h1>ho</h1>"^^rdf:HTML  . """

    p = g.parse(data=y, format="turtle")
    p.serialize(format="turtle")


if __name__ == "__main__":
    test_sort_docfrag()