Commit 190cc4e
committed
fix .// xpath queries
Previously, when iter() encountered a non-Element child (like a text string), it would yield it unconditionally, even if the caller was searching for a specific tag (e.g., .//c).
```
def test_Element_findall_dotslashslash():
c1 = Element('c')
c2 = Element('c')
text = "text"
b1 = Element('b', children=(c1, text, c2))
b2 = Element('b')
a1 = Element('a', children=(b1, b2, ))
result = list(a1.findall('.//c'))
> assert len(result) == 2
E AssertionError: assert 3 == 2
E + where 3 = len([<Element 'c' at 1056c4450>, 'text', <Element 'c' at 1056c4810>])
src/emeraldtree/tests/test_tree.py:208: AssertionError
```
The fix ensures that non-Element children are only yielded if no tag filter is specified (tag is None).1 parent db127d7 commit 190cc4e
2 files changed
+2
-3
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
184 | 184 | | |
185 | 185 | | |
186 | 186 | | |
187 | | - | |
188 | 187 | | |
189 | 188 | | |
190 | 189 | | |
| |||
199 | 198 | | |
200 | 199 | | |
201 | 200 | | |
202 | | - | |
203 | 201 | | |
204 | 202 | | |
205 | 203 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
355 | 355 | | |
356 | 356 | | |
357 | 357 | | |
358 | | - | |
| 358 | + | |
| 359 | + | |
359 | 360 | | |
360 | 361 | | |
361 | 362 | | |
| |||
0 commit comments