Notice: If you are member of any public project or group, please make sure that your GitLab username is not the same as the LRZ identifier/Kennung (see Please change your username if necessary. For more information see the section "Public projects / Öffentliche Projekte" at . Thank you!

Commit afda6166 authored by di68kap's avatar di68kap

- added Node.index()-method

parent abb212a2
......@@ -505,6 +505,7 @@ class Node: # ( Base class omitted for cython-compatibil
if child.tag_name == tag_name:
return i
i += 1
raise ValueError("Node with tag name '%s' not among child-nodes." % tag_name)
def select(self, match_function: Callable, include_root: bool = False, reverse: bool = False) \
-> Iterator['Node']:
......@@ -317,6 +317,17 @@ class TestNodeFind():
assert 'c' not in tree
assert any(tree.select_by_tag('c', False))
def test_index(self):
tree = parse_sxpr('(a (b 0) (c 1) (d 2))')
assert tree.index('d') == 2
assert tree.index('b') == 0
assert tree.index('c') == 1
i = tree.index('x')
raise AssertionError('ValueError expected!')
except ValueError:
class TestSerialization:
def test_sxpr_roundtrip(self):
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment