Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
cubicweb
cubes
skos
Commits
c3ea5c5c5020
Commit
a1f761c0
authored
Mar 31, 2015
by
Erica Marco
Browse files
[rdfio] implement == and != for unicode_with_language
parent
909aec271ea4
Changes
2
Hide whitespace changes
Inline
Side-by-side
rdfio.py
View file @
c3ea5c5c
...
...
@@ -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
)
else
:
return
super
(
unicode_with_language
,
self
).
__eq__
(
other
)
def
__ne__
(
self
,
other
):
return
not
self
==
other
class
RDFRegistryError
(
Exception
):
pass
...
...
test/unittest_rdfio.py
View file @
c3ea5c5c
...
...
@@ -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
):
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment