Commit a1f761c0 authored by Erica Marco's avatar Erica Marco
Browse files

[rdfio] implement == and != for unicode_with_language

parent 909aec271ea4
......@@ -28,6 +28,15 @@ class unicode_with_language(unicode):
self.lang = lang
return self
def __eq__(self, other):
if isinstance(other, unicode_with_language):
return (unicode(self), self.lang) == (unicode(other), other.lang)
return super(unicode_with_language, self).__eq__(other)
def __ne__(self, other):
return not self == other
class RDFRegistryError(Exception):
......@@ -23,7 +23,31 @@ from logilab.common.testlib import TestCase, require_module, unittest_main
from cubicweb import devtools # XXX ensure python path is ok
from cubes.skos import ExtEntity
from cubes.skos.rdfio import (RDFRegistryError, RDFRegistry, RDFLibRDFGraph,
LibRDFRDFGraph, rdf_graph_to_entities)
LibRDFRDFGraph, rdf_graph_to_entities, unicode_with_language as ul)
class UnicodeWithLanguageTC(TestCase):
def test_comparison_ul_ul(self):
a = ul('toto', 'fr')
b = ul('toto', 'fr')
self.assertEqual(a, b)
b = ul('toto', 'en')
self.assertNotEqual(a, b)
b = ul('titi', 'fr')
self.assertNotEqual(a, b)
def test_comparison_ul_and_other(self):
a = ul('toto', 'fr')
b = u'toto'
self.assertEqual(a, b)
b = u'titi'
self.assertNotEqual(a, b)
b = 3
self.assertNotEqual(a, b)
class RDFRegistryTC(TestCase):
def setUp(self):
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment