# tff.test.with_context

<br />

|---|
| [![](https://www.tensorflow.org/images/GitHub-Mark-32px.png) View source on GitHub](https://github.com/tensorflow/federated/blob/v0.87.0 Version 2.0, January 2004 Licensed under the Apache License, Version 2.0 (the) |

Returns a decorator for running a test in a context.

    tff.test.with_context(
        context_fn: _ContextFactory,
        environment_fn: Optional[_EnvironmentFactory] = None
    )

<br />

<br />

<br />

| ## Args ||
|---|---|
| `context_fn` | A `Callable` that constructs a [`tff.framework.AsyncContext`](https://www.tensorflow.org/federated/api_docs/python/tff/framework/AsyncContext) or [`tff.framework.SyncContext`](https://www.tensorflow.org/federated/api_docs/python/tff/framework/SyncContext) to install beore invoking the decorated function. |
| `environment_fn` | A `Callable` that constructs a list of `contextlib.AbstractContextManager` to enter before invoking the decorated function. |

<br />