fixture.util

Fixture utilties.

class fixture.util.DataTestCase

Bases: object

A mixin to use with unittest.TestCase.

Upon setUp() the TestCase will load the DataSet classes using your Fixture, specified in class variables. At tearDown(), all loaded data will be removed. During your test, you will have self.data, a SuperSet instance to reference loaded data

Class Attributes:

fixture
the Fixture instance to load DataSet classes with
datasets
A list of DataSet classes to load
data
self.data, a Fixture.Data instance populated for you after setUp()
fixture.util.with_debug(*channels, **kw)

A nose decorator calls start_debug() / start_debug() before and after the decorated method.

All positional arguments are considered channels that should be debugged. Keyword arguments are passed to start_debug()

fixture.util.reset_log_level(level=50, channels=('fixture.loadable', 'fixture.loadable.tree'))

Resets the level on all fixture logs.

You may need to call this when other applications reset the root logger’s log level.

Calling this with no args sets all logs to logging.CRITICAL which should keep them quiet

Added in version 1.1

fixture.util.start_debug(channel, stream=<open file '<stdout>', mode 'w' at 0x17068>, handler=None, level=10)

A shortcut to start logging a channel to a stream.

For example:

>>> from fixture.util import start_debug, stop_debug
>>> start_debug("fixture.loadable")

starts logging messages from the fixture.loadable channel to the stream. Then...

>>> stop_debug("fixture.loadable")

...turns it off.

Available Channels:

fixture.loadable
logs LOAD and CLEAR messages, referring to dataset actions
fixture.loadable.tree
logs a tree view of datasets loaded by datasets (recursion)

Keyword Arguments:

stream
stream to create a loggin.StreamHandler with. defaults to stdout.
handler
a preconfigured handler to add to the log
level
a logging level to set, default is logging.DEBUG

Note

Other applications might add a handler to the root logger, in which case you can’t turn off debug output without messing with the root logger.

fixture.util.stop_debug(channel=None)
The reverse of start_debug().

Previous topic

fixture.style