testtools.content.Content(object)
class documentationtesttools.content
(View In Hierarchy)
Known subclasses: testtools.content.StackLinesContent, testtools.content.TracebackContent
A MIME-like Content object.
'Content' objects can be serialised to bytes using the iter_bytes method. If the 'Content-Type' is recognised by other code, they are welcome to look for richer contents that mere byte serialisation - for example in memory object graphs etc. However, such code MUST be prepared to receive a generic 'Content' object that has been reconstructed from a byte stream.
Instance Variable | content_type | The content type of this Content. |
Method | __init__ | Create a ContentType. |
Method | __eq__ | Undocumented |
Method | as_text | Return all of the content as text. |
Method | iter_bytes | Iterate over bytestrings of the serialised content. |
Method | iter_text | Iterate over the text of the serialised content. |
Method | __repr__ | Undocumented |
Method | _iter_text | Worker for iter_text - does the decoding. |
Return all of the content as text.
This is only valid where iter_text is. It will load all of the content into memory. Where this is a concern, use iter_text instead.
Iterate over the text of the serialised content.
This is only valid for text MIME types, and will use ISO-8859-1 if no charset parameter is present in the MIME type. (This is somewhat arbitrary, but consistent with RFC2617 3.7.1).
Raises | ValueError | If the content type is not text/*. |