[Lxml-checkins] r38871 - in lxml/trunk: . src/lxml src/lxml/tests
scoder at codespeak.net
scoder at codespeak.net
Thu Feb 15 09:30:34 CET 2007
Author: scoder
Date: Thu Feb 15 09:30:32 2007
New Revision: 38871
Modified:
lxml/trunk/CHANGES.txt
lxml/trunk/src/lxml/etree.pyx
lxml/trunk/src/lxml/tests/test_elementtree.py
Log:
rich comparison of QName objects
Modified: lxml/trunk/CHANGES.txt
==============================================================================
--- lxml/trunk/CHANGES.txt (original)
+++ lxml/trunk/CHANGES.txt Thu Feb 15 09:30:32 2007
@@ -8,6 +8,8 @@
Features added
--------------
+* Rich comparison of QName objects
+
* Support for regular expressions in benchmark selection
* get/set emulation (not .attrib!) for attributes on processing instructions
Modified: lxml/trunk/src/lxml/etree.pyx
==============================================================================
--- lxml/trunk/src/lxml/etree.pyx (original)
+++ lxml/trunk/src/lxml/etree.pyx Thu Feb 15 09:30:32 2007
@@ -210,6 +210,9 @@
return self.text
def __hash__(self):
return self.text.__hash__()
+ def __richcmp__(one, other, int op):
+ return python.PyObject_RichCompare(
+ str(one), str(other), op)
# forward declaration of _BaseParser, see parser.pxi
Modified: lxml/trunk/src/lxml/tests/test_elementtree.py
==============================================================================
--- lxml/trunk/src/lxml/tests/test_elementtree.py (original)
+++ lxml/trunk/src/lxml/tests/test_elementtree.py Thu Feb 15 09:30:32 2007
@@ -2320,6 +2320,15 @@
self.assertEquals(a1.tag, "{myns}a")
self.assertEquals(a2.tag, "{myns}a")
+ def test_qname_cmp(self):
+ etree = self.etree
+ qname1 = etree.QName('myns', 'a')
+ qname2 = etree.QName('myns', 'a')
+ self.assertEquals(qname1, "{myns}a")
+ self.assertEquals("{myns}a", qname2)
+ self.assertEquals(qname1, qname1)
+ self.assertEquals(qname1, qname2)
+
def _writeElement(self, element, encoding='us-ascii'):
"""Write out element for comparison.
"""
More information about the lxml-checkins
mailing list