def as_fixture(self, name=None):
        """
        A decorator to inject this container into a function as a test fixture.
        """
        if name is None:
            name = self.name

        def deco(f):
            @functools.wraps(f)
            def wrapper(*args, **kw):
                with self:
                    kw[name] = self
                    return f(*args, **kw)
            return wrapper
        return deco
A decorator to inject this container into a function as a test fixture.