From b624d75b18b6644adb1e783e1032cbf74da409e7 Mon Sep 17 00:00:00 2001 From: Robert Collins Date: Wed, 1 Jul 2015 16:11:59 +1200 Subject: Update documentation --- apidocs/testtools.content.html | 311 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 311 insertions(+) create mode 100644 apidocs/testtools.content.html (limited to 'apidocs/testtools.content.html') diff --git a/apidocs/testtools.content.html b/apidocs/testtools.content.html new file mode 100644 index 0000000..c11abd6 --- /dev/null +++ b/apidocs/testtools.content.html @@ -0,0 +1,311 @@ + + + + + testtools.content : API documentation + + + + + + + + + +
+ + + +
+ +
+ +
+
Content - a MIME-like Content object.
+
+ +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
ClassContentA MIME-like Content object.
ClassStackLinesContentContent object for stack lines.
ClassTracebackContentContent object for tracebacks.
FunctionStacktraceContentContent object for stack traces.
Functionjson_contentCreate a JSON Content object from JSON-encodeable data.
Functiontext_contentCreate a Content object from some text.
Functionmaybe_wrapMerge metadata for func into wrapper if functools is present.
Functioncontent_from_fileCreate a Content object from a file on disk.
Functioncontent_from_streamCreate a Content object from a file-like stream.
Functioncontent_from_readerCreate a Content object that will obtain the content from reader.
Functionattach_fileAttach a file to this test as a detail.
Function_iter_chunksRead 'stream' in chunks of 'chunk_size'.
+ + + +
+ +
+ +
+ + + + + + +
+ + def + _iter_chunks(stream, chunk_size, seek_offset=None, seek_whence=0): + +
+
+ +
Read 'stream' in chunks of 'chunk_size'.
ParametersstreamA file-like object to read from.
chunk_sizeThe size of each read from 'stream'.
seek_offsetIf non-None, seek before iterating.
seek_whencePass through to the seek call, if seeking.
+
+
+ + + + + + +
+ + def + StacktraceContent(prefix_content='', postfix_content=''): + +
+
+ +

Content object for stack traces.

+

This function will create and return a 'Content' object that contains a +stack trace.

+

The mime type is set to 'text/x-traceback;language=python', so other +languages can format their stack traces differently.

Parametersprefix_contentA unicode string to add before the stack lines.
postfix_contentA unicode string to add after the stack lines.
+
+
+ + + + + + +
+ + def + json_content(json_data): + +
+
+ +
Create a JSON Content object from JSON-encodeable data.
+
+
+ + + + + + +
+ + def + text_content(text): + +
+
+ +

Create a Content object from some text.

+

This is useful for adding details which are short strings.

+
+
+ + + + + + +
+ + def + maybe_wrap(wrapper, func): + +
+
+ +
Merge metadata for func into wrapper if functools is present.
+
+
+ + + + + + +
+ + def + content_from_file(path, content_type=None, chunk_size=DEFAULT_CHUNK_SIZE, buffer_now=False, seek_offset=None, seek_whence=0): + +
+
+ +

Create a Content object from a file on disk.

+

Note that unless buffer_now is explicitly passed in as True, the file +will only be read from when iter_bytes is called.

ParameterspathThe path to the file to be used as content.
content_typeThe type of content. If not specified, defaults +to UTF8-encoded text/plain.
chunk_sizeThe size of chunks to read from the file. +Defaults to DEFAULT_CHUNK_SIZE.
buffer_nowIf True, read the file from disk now and keep it in +memory. Otherwise, only read when the content is serialized.
seek_offsetIf non-None, seek within the stream before reading it.
seek_whenceIf supplied, pass to stream.seek() when seeking.
+
+
+ + + + + + +
+ + def + content_from_stream(stream, content_type=None, chunk_size=DEFAULT_CHUNK_SIZE, buffer_now=False, seek_offset=None, seek_whence=0): + +
+
+ +

Create a Content object from a file-like stream.

+

Note that unless buffer_now is explicitly passed in as True, the stream +will only be read from when iter_bytes is called.

ParametersstreamA file-like object to read the content from. The stream +is not closed by this function or the 'Content' object it returns.
content_typeThe type of content. If not specified, defaults +to UTF8-encoded text/plain.
chunk_sizeThe size of chunks to read from the file. +Defaults to DEFAULT_CHUNK_SIZE.
buffer_nowIf True, reads from the stream right now. Otherwise, +only reads when the content is serialized. Defaults to False.
seek_offsetIf non-None, seek within the stream before reading it.
seek_whenceIf supplied, pass to stream.seek() when seeking.
+
+
+ + + + + + +
+ + def + content_from_reader(reader, content_type, buffer_now): + +
+
+ +
Create a Content object that will obtain the content from reader.
ParametersreaderA callback to read the content. Should return an iterable of +bytestrings.
content_typeThe content type to create.
buffer_nowIf True the reader is evaluated immediately and +buffered.
+
+
+ + + + + + +
+ + def + attach_file(detailed, path, name=None, content_type=None, chunk_size=DEFAULT_CHUNK_SIZE, buffer_now=True): + +
+
+ +

Attach a file to this test as a detail.

+

This is a convenience method wrapping around addDetail.

+

Note that by default the contents of the file will be read immediately. If +buffer_now is False, then the file must exist when the test result is +called with the results of this test, after the test has been torn down.

ParametersdetailedAn object with details
pathThe path to the file to attach.
nameThe name to give to the detail for the attached file.
content_typeThe content type of the file. If not provided, +defaults to UTF8-encoded text/plain.
chunk_sizeThe size of chunks to read from the file. Defaults +to something sensible.
buffer_now

If False the file content is read when the content +object is evaluated rather than when attach_file is called. +Note that this may be after any cleanups that obj_with_details has, so +if the file is a temporary file disabling buffer_now may cause the file +to be read after it is deleted. To handle those cases, using +attach_file as a cleanup is recommended because it guarantees a +sequence for when the attach_file call is made:

+
+detailed.addCleanup(attach_file, 'foo.txt', detailed)
+
+
+
+ +
+
+ API Documentation for testtools, generated by pydoctor at 2015-07-01 16:11:28. +
+ +
+ + \ No newline at end of file -- cgit v1.2.1