plainbox.testing_utils.resource

Implementation of simple resource sharing cache for unit tests

class plainbox.testing_utils.resource.Dict[source]

A dict() that can be weakly referenced

See: http://docs.python.org/3/library/weakref.html

class plainbox.testing_utils.resource.List[source]

A list() that can be weakly referenced

See: http://docs.python.org/3/library/weakref.html

class plainbox.testing_utils.resource.ResourceCache(weak=True)[source]

Cache for expensive operations.

If your test needs to compute something (slowly) and reuse it in various different test_ methods then this will save time.

static convert_to_weakref_compat(obj)[source]

Convert the passed object to something that can be weakly reachable

get(key, operation)[source]

Get a value from the cache, falling back to computing it if needed

Gets something from the cache dictionary, referenced by the key. If the value is missing it is computed, by calling the operation, and stored in the cache.

Previous topic

plainbox.testing_utils.io – tools for testing IO

Next topic

plainbox.testing_utils.testcases – additional TestCase classes

This Page