[PR #3398] Enhance unit testing documentation with practical examples for fake chat models #3455

Open
opened 2026-06-05 18:23:10 -04:00 by yindo · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/langchain-ai/docs/pull/3398
Author: @alwaysahustler
Created: 4/1/2026
Status: 🔄 Open

Base: mainHead: patch-2


📝 Commits (3)

  • 89a060a Enhance unit testing documentation with examples
  • 19adc80 Revise unit testing examples for chat models
  • 23f3ec4 Fix import paths for message classes in unit tests

📊 Changes

1 file changed (+91 additions, -0 deletions)

View changed files

📝 src/oss/langchain/test/unit-testing.mdx (+91 -0)

📄 Description

Added examples for using FakeListChatModel and GenericFakeChatModel in testing. Included pytest fixtures for reusing fake models.

Overview

This update improves the unit testing documentation by adding clear, real-world examples demonstrating how to:

  • Use FakeListChatModel for simple deterministic responses
  • Use GenericFakeChatModel for advanced scenarios such as tool calling and multi-step interactions
  • Simulate the full agent loop: message → tool call → tool execution → final response
  • Reuse fake models across tests using pytest fixtures

Type of change

Type: Update existing documentation

Related issues/PRs

  • GitHub issue: N/A
  • Feature PR: N/A

Checklist

  • I have read the contributing guidelines, including the language policy
  • I have tested my changes locally using docs dev
  • All code examples have been tested and work correctly
  • I have used root relative paths for internal links
  • I have updated navigation in src/docs.json if needed

Additional notes

  • Emphasizes deterministic testing by controlling model outputs instead of relying on live LLMs
  • Clarifies when to use FakeListChatModel vs GenericFakeChatModel
  • Highlights iterator behavior in GenericFakeChatModel and correct pytest fixture usage
  • Examples are designed to be minimal and copy-pasteable

🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/langchain-ai/docs/pull/3398 **Author:** [@alwaysahustler](https://github.com/alwaysahustler) **Created:** 4/1/2026 **Status:** 🔄 Open **Base:** `main` ← **Head:** `patch-2` --- ### 📝 Commits (3) - [`89a060a`](https://github.com/langchain-ai/docs/commit/89a060a36d315ea8efeae8e99133590d324c7f1c) Enhance unit testing documentation with examples - [`19adc80`](https://github.com/langchain-ai/docs/commit/19adc8036582db9a909ab538a87d5e9c5228836b) Revise unit testing examples for chat models - [`23f3ec4`](https://github.com/langchain-ai/docs/commit/23f3ec45b3f81060b59bfb499c96452ce436f028) Fix import paths for message classes in unit tests ### 📊 Changes **1 file changed** (+91 additions, -0 deletions) <details> <summary>View changed files</summary> 📝 `src/oss/langchain/test/unit-testing.mdx` (+91 -0) </details> ### 📄 Description Added examples for using `FakeListChatModel` and `GenericFakeChatModel` in testing. Included pytest fixtures for reusing fake models. ## Overview This update improves the unit testing documentation by adding clear, real-world examples demonstrating how to: - Use `FakeListChatModel` for simple deterministic responses - Use `GenericFakeChatModel` for advanced scenarios such as tool calling and multi-step interactions - Simulate the full agent loop: message → tool call → tool execution → final response - Reuse fake models across tests using `pytest` fixtures ## Type of change **Type:** Update existing documentation ## Related issues/PRs - GitHub issue: N/A - Feature PR: N/A ## Checklist - [x] I have read the [contributing guidelines](README.md), including the [language policy](https://docs.langchain.com/oss/python/contributing/overview#language-policy) - [ ] I have tested my changes locally using `docs dev` - [x] All code examples have been tested and work correctly - [x] I have used **root relative** paths for internal links - [ ] I have updated navigation in `src/docs.json` if needed ## Additional notes - Emphasizes deterministic testing by controlling model outputs instead of relying on live LLMs - Clarifies when to use `FakeListChatModel` vs `GenericFakeChatModel` - Highlights iterator behavior in `GenericFakeChatModel` and correct pytest fixture usage - Examples are designed to be minimal and copy-pasteable --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
yindo added the pull-request label 2026-06-05 18:23:10 -04:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: langchain-ai/docs#3455