[Lxml-checkins] r32602 - in lxml/branch/lxml-1.1: . src/lxml src/lxml/tests
scoder at codespeak.net
scoder at codespeak.net
Sat Sep 23 08:01:57 CEST 2006
Author: scoder
Date: Sat Sep 23 08:01:53 2006
New Revision: 32602
Modified:
lxml/branch/lxml-1.1/CHANGES.txt
lxml/branch/lxml-1.1/src/lxml/objectify.pyx
lxml/branch/lxml-1.1/src/lxml/tests/test_objectify.py
Log:
'x * StringElement' operation
Modified: lxml/branch/lxml-1.1/CHANGES.txt
==============================================================================
--- lxml/branch/lxml-1.1/CHANGES.txt (original)
+++ lxml/branch/lxml-1.1/CHANGES.txt Sat Sep 23 08:01:53 2006
@@ -2,6 +2,19 @@
lxml changelog
==============
+=======
+current
+=======
+
+Features added
+--------------
+
+Bugs fixed
+----------
+
+* 'integer * objectify.StringElement' operation was not supported
+
+
1.1.1 (2006-09-21)
==================
Modified: lxml/branch/lxml-1.1/src/lxml/objectify.pyx
==============================================================================
--- lxml/branch/lxml-1.1/src/lxml/objectify.pyx (original)
+++ lxml/branch/lxml-1.1/src/lxml/objectify.pyx Sat Sep 23 08:01:53 2006
@@ -635,6 +635,8 @@
def __mul__(self, other):
if isinstance(self, StringElement):
return textOf((<StringElement>self)._c_node) * _numericValueOf(other)
+ elif isinstance(other, StringElement):
+ return _numericValueOf(self) * textOf((<StringElement>other)._c_node)
else:
raise TypeError, "invalid types for * operator"
Modified: lxml/branch/lxml-1.1/src/lxml/tests/test_objectify.py
==============================================================================
--- lxml/branch/lxml-1.1/src/lxml/tests/test_objectify.py (original)
+++ lxml/branch/lxml-1.1/src/lxml/tests/test_objectify.py Sat Sep 23 08:01:53 2006
@@ -273,6 +273,28 @@
root.none = "test"
self.assert_(isinstance(root.none, objectify.StringElement))
+ def test_type_str_mul(self):
+ Element = self.Element
+ SubElement = self.etree.SubElement
+ root = Element("{objectified}root")
+ root.none = "test"
+
+ self.assertEquals("test" * 5, root.none * 5)
+ self.assertEquals(5 * "test", 5 * root.none)
+
+ self.assertRaises(TypeError, operator.mul, root.none, "honk")
+ self.assertRaises(TypeError, operator.mul, "honk", root.none)
+
+ def test_type_str_add(self):
+ Element = self.Element
+ SubElement = self.etree.SubElement
+ root = Element("{objectified}root")
+ root.none = "test"
+
+ s = "toast"
+ self.assertEquals("test" + s, root.none + s)
+ self.assertEquals(s + "test", s + root.none)
+
def test_data_element_str(self):
value = objectify.DataElement("test")
self.assert_(isinstance(value, objectify.StringElement))
More information about the lxml-checkins
mailing list