self.assertEquals(1, len(find_all(t, "//ReturnStatNode")))
self.assertEquals(1, len(find_all(t, "//DefNode//ReturnStatNode")))
+ def test_node_path_attribute(self):
+ t = self._build_tree()
+ self.assertEquals(2, len(find_all(t, "//NameNode/@name")))
+ self.assertEquals(['fun', 'decorator'], find_all(t, "//NameNode/@name"))
+
def test_node_path_child(self):
t = self._build_tree()
self.assertEquals(1, len(find_all(t, "//DefNode/ReturnStatNode/NameNode")))
if token[0]:
raise ValueError("Expected attribute name")
name = token[1]
- token = next()
value = None
- if token[0] == '=':
- value = parse_path_value(next)
+ try:
+ token = next()
+ except StopIteration:
+ pass
+ else:
+ if token[0] == '=':
+ value = parse_path_value(next)
if value is None:
def select(result):
for node in result: