testtools.testcase
module documentationtesttools
Class | TestSkipped | Raised within TestCase.run() when a test is skipped. |
Function | run_test_with | Decorate a test as using a specific RunTest. |
Function | gather_details | Merge the details from source_dict into target_dict. |
Class | TestCase | Extensions to the basic TestCase. |
Function | clone_test_with_new_id | Copy a TestCase , and give the copied test a new id. |
Function | attr | Decorator for adding attributes to WithAttributes. |
Class | WithAttributes | A mix-in class for modifying test id by attributes. |
Function | skip | A decorator to skip unit tests. |
Function | skipIf | A decorator to skip a test if the condition is true. |
Function | skipUnless | A decorator to skip a test unless the condition is true. |
Class | ExpectedException | A context manager to handle expected exceptions. |
Class | Nullary | Turn a callable into a nullary callable. |
Class | _UnexpectedSuccess | An unexpected success was raised. |
Class | _ExpectedFailure | An expected failure occured. |
Function | _expectedFailure | Undocumented |
Function | _copy_content | Make a copy of the given content object. |
Function | _clone_test_id_callback | Copy a TestCase , and make it call callback for its id(). |
Decorate a test as using a specific RunTest.
e.g.:
@run_test_with(CustomRunner, timeout=42) def test_foo(self): self.assertTrue(True)
The returned decorator works by setting an attribute on the decorated
function. TestCase.__init__
looks for this attribute when deciding on a
RunTest factory. If you wish to use multiple decorators on a test
method, then you must either make this one the top-most decorator, or you
must write your decorators so that they update the wrapping function with
the attributes of the wrapped function. The latter is recommended style
anyway. functools.wraps, functools.wrapper and
twisted.python.util.mergeFunctionMetadata can help you do this.
Parameters | test_runner | A RunTest factory that takes a test case and an optional list of exception handlers. See RunTest. |
kwargs | Keyword arguments to pass on as extra arguments to 'test_runner'. | |
Returns | A decorator to be used for marking a test as needing a special runner. |
Make a copy of the given content object.
The content within content_object is iterated and saved. This is useful when the source of the content is volatile, a log file in a temporary directory for example.
Parameters | content_object | A content.Content instance. |
Returns | A content.Content instance with the same mime-type as
content_object and a non-volatile copy of its content. |
Parameters | source_dict | A dictionary of details will be gathered. |
target_dict | A dictionary into which details will be gathered. |
Copy a TestCase
, and make it call callback for its id().
This is only expected to be used on tests that have been constructed but not executed.
Parameters | test | A TestCase instance. |
callback | A callable that takes no parameters and returns a string. | |
Returns | A copy.copy of the test with id=callback. |
Copy a TestCase
, and give the copied test a new id.
This is only expected to be used on tests that have been constructed but not executed.
Parameters | args | The name of attributes to add. |
Returns | A callable that when applied to a WithAttributes will alter its id to enumerate the added attributes. |