Module t.t.util

Part of twisted.trial View Source

A collection of utility functions and classes, used internally by Trial.

API Stability: Unstable

This code is for Trial's internal use. Do NOT use this code if you are writing tests. It is subject to change at the Trial maintainer's whim. There is nothing here in this module for you to use unless you are maintaining Trial.

Any non-Trial Twisted code that uses this module will be shot.

Maintainer: Jonathan Lange
Class FailureError Wraps around a Failure so it can get re-raised as an Exception
Class DirtyReactorError emitted when the reactor has been left in an unclean state
Class DirtyReactorWarning emitted when the reactor has been left in an unclean state
Class PendingTimedCallsError raised when timed calls are left in the reactor
Class _Janitor Undocumented
Function suppress sets up the .suppress tuple properly, pass options to this method
Function profiled Undocumented
Function getPythonContainers Walk up the Python tree from method 'meth', finding its class, its module
Function acquireAttribute Go through the list 'objects' sequentially until we find one which has
Function findObject Get a fully-named package, module, module-global object or attribute.
def suppress(action='ignore', **kwarg): (source)

sets up the .suppress tuple properly, pass options to this method as you would the stdlib warnings.filterwarnings()

so to use this with a .suppress magic attribute you would do the following:
>>> from twisted.trial import unittest, util
>>> import warnings
>>>
>>> class TestFoo(unittest.TestCase):
...     def testFooBar(self):
...         warnings.warn("i am deprecated", DeprecationWarning)
...     testFooBar.suppress = [util.suppress(message='i am deprecated')]
...
>>>
note that as with the todo and timeout attributes: the module level attribute acts as a default for the class attribute which acts as a default for the method attribute. The suppress attribute can be overridden at any level by specifying .suppress = []
def profiled(f, outputFile): (source)
Undocumented
def getPythonContainers(meth): (source)
Walk up the Python tree from method 'meth', finding its class, its module and all containing packages.
def acquireAttribute(objects, attr, default=_DEFAULT): (source)
Go through the list 'objects' sequentially until we find one which has attribute 'attr', then return the value of that attribute. If not found, return 'default' if set, otherwise, raise AttributeError.
def findObject(name): (source)

Get a fully-named package, module, module-global object or attribute. Forked from twisted.python.reflect.namedAny.

Returns a tuple of (bool, obj). If bool is True, the named object exists and is returned as obj. If bool is False, the named object does not exist and the value of obj is unspecified.
API Documentation for twisted, generated by pydoctor.