> For clean Markdown of any page, append .md to the page URL.
> For a complete documentation index, see https://docs.nvidia.com/nemo/guardrails/llms.txt.
> For full documentation content, see https://docs.nvidia.com/nemo/guardrails/llms-full.txt.
> For AI client integration (Claude Code, Cursor, etc.), connect to the MCP server at https://docs.nvidia.com/nemo/guardrails/_mcp/server.

# nemoguardrails.testing.fixtures

Pytest fixtures exposing the public testing surface.

To opt in, add the following to your project's `conftest.py`::

pytest\_plugins = \["nemoguardrails.testing.fixtures"]

The fixtures below provide reasonable defaults that cover the most common
testing patterns: a scriptable :class:`FakeLLMModel` and a :class:`TestChat`
factory that wires the fake model into an :class:`LLMRails` app.

## Module Contents

### Functions

| Name                                                                | Description                                                         |
| ------------------------------------------------------------------- | ------------------------------------------------------------------- |
| [`fake_llm`](#nemoguardrails-testing-fixtures-fake_llm)             | Return a :class:`FakeLLMModel` with a single `"Hello!"` response.   |
| [`make_fake_llm`](#nemoguardrails-testing-fixtures-make_fake_llm)   | Return a factory for building :class:`FakeLLMModel` instances.      |
| [`make_test_chat`](#nemoguardrails-testing-fixtures-make_test_chat) | Return a factory that builds :class:`TestChat` instances bound to a |

### API

```python
nemoguardrails.testing.fixtures.fake_llm() -> nemoguardrails.testing.fake_model.FakeLLMModel
```

Return a :class:`FakeLLMModel` with a single `"Hello!"` response.

Override the responses by overriding this fixture in your own conftest, or
instantiate :class:`FakeLLMModel` directly when you need custom behaviour::

from nemoguardrails.testing import FakeLLMModel

llm = FakeLLMModel(responses=\["My scripted answer"])

```python
nemoguardrails.testing.fixtures.make_fake_llm() -> typing.Callable[..., nemoguardrails.testing.fake_model.FakeLLMModel]
```

Return a factory for building :class:`FakeLLMModel` instances.

Useful when a single test needs more than one fake model, or when the set
of responses is computed dynamically::

def test\_two\_calls(make\_fake\_llm):
llm\_one = make\_fake\_llm(responses=\["one"])
llm\_two = make\_fake\_llm(responses=\["two"])

```python
nemoguardrails.testing.fixtures.make_test_chat() -> typing.Callable[..., nemoguardrails.testing.chat_harness.TestChat]
```

Return a factory that builds :class:`TestChat` instances bound to a
fake LLM.

Example::

def test\_greeting(make\_test\_chat):
config = RailsConfig.from\_path("./examples/bots/abc")
chat = make\_test\_chat(config, llm\_completions=\["Hi there!"])
chat.user("hi")
chat.bot("Hi there!")