summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJoern Hees <dev@joernhees.de>2015-11-28 13:25:27 +0100
committerJoern Hees <dev@joernhees.de>2015-11-28 13:25:27 +0100
commitae1f6397fe47be7bd6912dae8b08c4007eb9d2ac (patch)
treeea49e41b75fe8ae87a277cb3841efd2a1e01507e
parent0d79d7aee54f5de97878ba7501e59cdc88d855f1 (diff)
parent3d89d8e3301ae2de1a6996232f3b594bbf44d530 (diff)
downloadrdflib-ae1f6397fe47be7bd6912dae8b08c4007eb9d2ac.tar.gz
Merge branch 'closednamedspace-inheritance-fix'
* closednamedspace-inheritance-fix: re-introduces special handling for DCTERMS.title and test for it
-rw-r--r--rdflib/namespace.py5
-rw-r--r--test/test_namespace.py11
2 files changed, 14 insertions, 2 deletions
diff --git a/rdflib/namespace.py b/rdflib/namespace.py
index d98b28be..027a9e73 100644
--- a/rdflib/namespace.py
+++ b/rdflib/namespace.py
@@ -95,6 +95,11 @@ class Namespace(unicode):
rt = unicode.__new__(cls, value, 'utf-8')
return rt
+ @property
+ def title(self):
+ # overrides unicode.title to allow DCTERMS.title for example
+ return URIRef(self + 'title')
+
def term(self, name):
# need to handle slices explicitly because of __getitem__ override
return URIRef(self + (name if isinstance(name, basestring) else ''))
diff --git a/test/test_namespace.py b/test/test_namespace.py
index d6aa8e68..7975220b 100644
--- a/test/test_namespace.py
+++ b/test/test_namespace.py
@@ -1,9 +1,16 @@
import unittest
+from rdflib.namespace import DCTERMS
from rdflib.graph import Graph
from rdflib.term import URIRef
from rdflib.py3compat import b
+
+class NamespaceTest(unittest.TestCase):
+ def test_dcterms_title(self):
+ self.assertEqual(DCTERMS.title, URIRef(DCTERMS + 'title'))
+
+
class NamespacePrefixTest(unittest.TestCase):
def test_compute_qname(self):
@@ -14,7 +21,7 @@ class NamespacePrefixTest(unittest.TestCase):
self.assertEqual(g.compute_qname(URIRef("http://foo/bar#baz")),
("ns2", URIRef("http://foo/bar#"), "baz"))
-
+
# should skip to ns4 when ns3 is already assigned
g.bind("ns3", URIRef("http://example.org/"))
self.assertEqual(g.compute_qname(URIRef("http://blip/blop")),
@@ -28,7 +35,7 @@ class NamespacePrefixTest(unittest.TestCase):
n3 = g.serialize(format="n3")
# Gunnar disagrees that this is right:
# self.assertTrue("<http://example.com/foo> ns1:bar <http://example.com/baz> ." in n3)
- # as this is much prettier, and ns1 is already defined:
+ # as this is much prettier, and ns1 is already defined:
self.assertTrue(b("ns1:foo ns1:bar ns1:baz .") in n3)
def test_n32(self):