MCPcopy Create free account
hub / github.com/Pylons/webtest / PyQuery

Method PyQuery

webtest/response.py:500–526  ·  view source on GitHub ↗

Same as `pyquery` but allow to pass arguments to initialize the `PyQuery` instance:: pq = resp.PyQuery(parser='xml', remove_namespaces=True)

(self, **kwargs)

Source from the content-addressed store, hash-verified

498 return self.PyQuery(parser='html')
499
500 def PyQuery(self, **kwargs):
501 """
502 Same as `pyquery` but allow to pass arguments to initialize the
503 `PyQuery` instance::
504
505 pq = resp.PyQuery(parser='xml', remove_namespaces=True)
506
507 """
508 if 'html' not in self.content_type and 'xml' not in self.content_type:
509 raise AttributeError(
510 "Not an HTML or XML response body (content-type: %s)"
511 % self.content_type)
512 try:
513 from pyquery import PyQuery
514 except ImportError: # pragma: no cover
515 raise ImportError(
516 "You must have PyQuery installed to use response.pyquery")
517 remove_namespaces = kwargs.pop('remove_namespaces', False)
518 parser = kwargs.get('parser', 'html')
519 if parser == 'xml':
520 body = self.body
521 else:
522 body = self.testbody
523 d = PyQuery(body, **kwargs)
524 if remove_namespaces:
525 d.remove_namespaces()
526 return d
527
528 def showbrowser(self):
529 """

Callers 2

pyqueryMethod · 0.95
test_pyqueryMethod · 0.80

Calls 1

getMethod · 0.45

Tested by 1

test_pyqueryMethod · 0.64