Back to index

moin  1.9.0~rc2
Public Member Functions | Public Attributes | Static Public Attributes Class Reference
Inheritance diagram for
Inheritance graph
Collaboration diagram for
Collaboration graph

List of all members.

Public Member Functions

def xml
def lxml
def json

Public Attributes


Static Public Attributes

tuple xml = cached_property(xml)
tuple lxml = cached_property(lxml)
tuple json = cached_property(json)

Detailed Description

Pass this to `werkzeug.test.Client` for easier unittesting.

Definition at line 65 of file

Member Function Documentation

Get the result of simplejson.loads if possible.

Definition at line 53 of file

00054     def json(self):
00055         """Get the result of simplejson.loads if possible."""
00056         if 'json' not in self.mimetype:
00057             raise AttributeError('Not a JSON response')
00058         try:
00059             from simplejson import loads
00060         except:
00061             from json import loads
        return loads(

Here is the call graph for this function:

Get an lxml etree if possible.

Definition at line 39 of file

00040     def lxml(self):
00041         """Get an lxml etree if possible."""
00042         if ('html' not in self.mimetype and 'xml' not in self.mimetype):
00043             raise AttributeError('Not an HTML/XML response')
00044         from lxml import etree
00045         try:
00046             from lxml.html import fromstring
00047         except ImportError:
00048             fromstring = etree.HTML
00049         if self.mimetype=='text/html':
00050             return fromstring(
        return etree.XML(
A mixin class for response objects that provides a couple of useful
accessors for unittesting.
Get an etree if possible.

Definition at line 24 of file

00025     def xml(self):
00026         """Get an etree if possible."""
00027         if 'xml' not in self.mimetype:
00028             raise AttributeError(
00029                 'Not a XML response (Content-Type: %s)'
00030                 % self.mimetype)
00031         for module in ['xml.etree.ElementTree', 'ElementTree',
00032                        'elementtree.ElementTree']:
00033             etree = import_string(module, silent=True)
00034             if etree is not None:
00035                 return etree.XML(self.body)
00036         raise RuntimeError('You must have ElementTree installed '
                           'to use TestResponse.xml')

Here is the call graph for this function:

Member Data Documentation

tuple = cached_property(json) [static, inherited]

Definition at line 62 of file

tuple = cached_property(lxml) [static, inherited]

Definition at line 51 of file

Definition at line 48 of file

tuple = cached_property(xml) [static, inherited]

Definition at line 37 of file

The documentation for this class was generated from the following file: