comparison emeraldtree/tests/test_tree.py @ 61:6c0a8bd9aa9a

more xpath attribute tests (with other and without value)
author Thomas Waldmann Tue, 18 May 2010 14:58:05 +0200 0c6020f1a2be 354ac088cd8d
comparison
equal inserted replaced
60:0c6020f1a2be 61:6c0a8bd9aa9a
216 text = u"text" 216 text = u"text"
217 b1 = Element(u'b', children=(c1, text, c2)) 217 b1 = Element(u'b', children=(c1, text, c2))
218 b2 = Element(u'b') 218 b2 = Element(u'b')
219 a1 = Element(u'a', children=(b1, b2, )) 219 a1 = Element(u'a', children=(b1, b2, ))
220 220
221 result = list(b1.findall(u"c[@testattr]"))
222 # note: does not work without c, like b1.findall(u"[@testattr]") - should it?
223 assert len(result) == 1
224 assert result[0] is c2
225
221 result = list(b1.findall(u"c[@testattr='testvalue']")) 226 result = list(b1.findall(u"c[@testattr='testvalue']"))
222 # note: does not work without c, like b1.findall(u"[@testattr='testvalue']") - should it? 227 # note: does not work without c, like b1.findall(u"[@testattr='testvalue']") - should it?
223 assert len(result) == 1 228 assert len(result) == 1
224 assert result[0] is c2 229 assert result[0] is c2
230
231 result = list(b1.findall(u"c[@testattr='othervalue']"))
232 # note: does not work without c, like b1.findall(u"[@testattr='othervalue']") - should it?
233 assert len(result) == 0
225 234
226 def test_Element_findall_position(): 235 def test_Element_findall_position():
227 py.test.skip('not supported') 236 py.test.skip('not supported')
228 c1 = Element(u'c') 237 c1 = Element(u'c')
229 c2 = Element(u'c') 238 c2 = Element(u'c')