File: test_prefixTypes.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 (34 lines) | stat: -rw-r--r-- 740 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
import unittest

from rdflib import Graph

graph = Graph().parse(
    format="n3",
    data="""
@prefix dct: <http://purl.org/dc/terms/> .
@prefix foaf: <http://xmlns.com/foaf/0.1/> .
@prefix xsd: <http://www.w3.org/2001/XMLSchema#> .

<http://example.org/doc> a foaf:Document;
    dct:created "2011-03-20"^^xsd:date .
""",
)


class PrefixTypesTest(unittest.TestCase):

    """N3/Turtle serializers should use prefixes,
    also for types and datatypes

    This is issue 161
    http://code.google.com/p/rdflib/issues/detail?id=161
    """

    def test(self):
        s = graph.serialize(format="n3")
        self.assertTrue("foaf:Document" in s)
        self.assertTrue("xsd:date" in s)


if __name__ == "__main__":
    unittest.main()