Commits

Anonymous committed 1f6cb67

Report error when position predicates are used in XPath expressions (which is NYI).

Comments (0)

Files changed (2)

         assert self.cur_token == '['
         self.next_token()
         expr = self._or_expr()
+        if isinstance(expr, NumberLiteral):
+            raise PathSyntaxError('Position predicates not yet supported')
         if self.cur_token != ']':
             raise PathSyntaxError('Expected "]" to close predicate, '
                                   'but found "%s"' % self.cur_token,

markup/tests/path.py

         self.assertRaises(PathSyntaxError, Path, '..')
         self.assertRaises(PathSyntaxError, Path, 'parent::ma')
 
+    def test_error_position_predicate(self):
+        self.assertRaises(PathSyntaxError, Path, 'item[0]')
+
     def test_1step(self):
         xml = XML('<root><elem/></root>')