File: test_issue161.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 (30 lines) | stat: -rw-r--r-- 976 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
from unittest import TestCase
from rdflib.graph import ConjunctiveGraph


class EntityTest(TestCase):
    def test_turtle_namespace_prefixes(self):

        g = ConjunctiveGraph()
        n3 = """
        @prefix _9: <http://data.linkedmdb.org/resource/movie/> .
        @prefix p_9: <urn:test:> .
        @prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#> .

        p_9:a p_9:b p_9:c .

        <http://data.linkedmdb.org/resource/director/1> a
        <http://data.linkedmdb.org/resource/movie/director>;
            rdfs:label "Cecil B. DeMille (Director)";
            _9:director_name "Cecil B. DeMille" ."""

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

        # Check round-tripping, just for kicks.
        g = ConjunctiveGraph()
        g.parse(data=turtle, format="turtle")
        # Shouldn't have got to here
        s = g.serialize(format="turtle", encoding="latin-1")

        self.assertTrue(b"@prefix _9" not in s)