Exemple #1
0
 def test_init_raises_ValueError_when_passing_bad_op_and_parent(self):
     fn = lambda: xpathselect.Query(None, b'//', b'..')
     self.assertThat(
         fn,
         raises(
             InvalidXPathQuery(
                 "Operation must be CHILD while selecting a parent")))
Exemple #2
0
 def test_init_raises_ValueError_when_passing_filters_and_parent(self):
     fn = lambda: xpathselect.Query(None, b'/', b'..', dict(foo=123))
     self.assertThat(
         fn,
         raises(
             InvalidXPathQuery(
                 "Cannot specify filters while selecting a parent")))
Exemple #3
0
 def test_init_raises_TypeError_on_invalid_operation_type(self):
     fn = lambda: xpathselect.Query(None, '/', b'sdf')
     self.assertThat(
         fn,
         raises(
             TypeError("'operation' parameter must be bytes, not '%s'" %
                       type('').__name__)))
Exemple #4
0
 def test_query_raises_TypeError_on_non_bytes_query(self):
     fn = lambda: xpathselect.Query(None, xpathselect.Query.Operation.CHILD,
                                    'asd')
     self.assertThat(
         fn,
         raises(
             TypeError("'query' parameter must be bytes, not %s" %
                       type('').__name__)))
Exemple #5
0
 def test_init_raises_ValueError_on_invalid_descendant_search(self):
     fn = lambda: xpathselect.Query(None, b'//', b'*')
     self.assertThat(
         fn,
         raises(
             InvalidXPathQuery(
                 "Must provide at least one server-side filter when searching "
                 "for descendants and using a wildcard node.")))
Exemple #6
0
 def test_init_raises_ValueError_on_invalid_operation(self):
     fn = lambda: xpathselect.Query(None, b'foo', b'sdf')
     self.assertThat(fn,
                     raises(InvalidXPathQuery("Invalid operation 'foo'.")))