summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorscoder <none@none>2008-01-24 22:32:09 +0100
committerscoder <none@none>2008-01-24 22:32:09 +0100
commite75051747e9e2e0607ce1e08a483efc9b30972b4 (patch)
tree1401db76dc5fb739eac697bd18fbba92ef0dbdaa /src
parente61ba3cbbd31f6d4858d454d9f439a91b4ea433a (diff)
downloadpython-lxml-e75051747e9e2e0607ce1e08a483efc9b30972b4.tar.gz
[svn r3199] r3312@delle: sbehnel | 2008-01-24 22:31:48 +0100
implementation of 'del el.text' and 'del el.tail', currently disabled due to unclear semantics --HG-- branch : trunk
Diffstat (limited to 'src')
-rw-r--r--src/lxml/lxml.etree.pyx8
-rw-r--r--src/lxml/tests/test_elementtree.py27
2 files changed, 35 insertions, 0 deletions
diff --git a/src/lxml/lxml.etree.pyx b/src/lxml/lxml.etree.pyx
index f0b0edfd..c86e87f0 100644
--- a/src/lxml/lxml.etree.pyx
+++ b/src/lxml/lxml.etree.pyx
@@ -787,6 +787,10 @@ cdef public class _Element [ type LxmlElementType, object LxmlElement ]:
_resolveQNameText(self, value), 'UTF-8', 'strict')
_setNodeText(self._c_node, value)
+ # using 'del el.text' is the wrong thing to do
+ #def __del__(self):
+ # _setNodeText(self._c_node, None)
+
property tail:
"""Text after this element's end tag, but before the next sibling
element's start tag. This is either a string or the value None, if
@@ -798,6 +802,10 @@ cdef public class _Element [ type LxmlElementType, object LxmlElement ]:
def __set__(self, value):
_setTailText(self._c_node, value)
+ # using 'del el.tail' is the wrong thing to do
+ #def __del__(self):
+ # _setTailText(self._c_node, None)
+
# not in ElementTree, read-only
property prefix:
"""Namespace prefix or None.
diff --git a/src/lxml/tests/test_elementtree.py b/src/lxml/tests/test_elementtree.py
index 940668f1..a49fa68b 100644
--- a/src/lxml/tests/test_elementtree.py
+++ b/src/lxml/tests/test_elementtree.py
@@ -224,6 +224,33 @@ class ETreeTestCaseBase(unittest.TestCase):
self.assertXML('<a><t></t>tail</a>',
a)
+ def _test_del_tail(self):
+ # this is discouraged for ET compat, should not be tested...
+ XML = self.etree.XML
+
+ root = XML('<doc>This is <i>mixed</i> content.</doc>')
+ self.assertEquals(1, len(root))
+ self.assertEquals('This is ', root.text)
+ self.assertEquals(None, root.tail)
+ self.assertEquals('mixed', root[0].text)
+ self.assertEquals(' content.', root[0].tail)
+
+ del root[0].tail
+
+ self.assertEquals(1, len(root))
+ self.assertEquals('This is ', root.text)
+ self.assertEquals(None, root.tail)
+ self.assertEquals('mixed', root[0].text)
+ self.assertEquals(None, root[0].tail)
+
+ root[0].tail = "TAIL"
+
+ self.assertEquals(1, len(root))
+ self.assertEquals('This is ', root.text)
+ self.assertEquals(None, root.tail)
+ self.assertEquals('mixed', root[0].text)
+ self.assertEquals('TAIL', root[0].tail)
+
def test_ElementTree(self):
Element = self.etree.Element
ElementTree = self.etree.ElementTree