pytest_agentic_fabric.mocking

Mocking helpers for tests that exercise agentic-fabric integrations.

Module Contents

Classes

FabricMocker

Convenience wrapper around pytest-mock for optional agent runtime tests.

Functions

agentic_fabric_mocker

Provide FabricMocker for agentic-fabric tests.

fabric_mocker

Provide the concise FabricMocker fixture name.

mock_agentic_frameworks

Mock every optional agent runtime framework.

mock_crewai

Mock CrewAI modules only.

mock_langgraph

Mock LangGraph modules only.

mock_strands

Mock Strands modules only.

Data

API

pytest_agentic_fabric.mocking.CREWAI_MODULES: tuple[str, ...] = ('crewai', 'crewai.knowledge', 'crewai.knowledge.source', 'crewai.knowledge.source.text_file_knowled...
pytest_agentic_fabric.mocking.LANGGRAPH_MODULES: tuple[str, ...] = ('langgraph', 'langgraph.prebuilt', 'langchain_anthropic')
pytest_agentic_fabric.mocking.STRANDS_MODULES: tuple[str, ...] = ('strands',)
pytest_agentic_fabric.mocking.RUNTIME_MODULES: dict[str, tuple[str, ...]] = None
pytest_agentic_fabric.mocking.ALL_FRAMEWORK_MODULES: tuple[str, ...] = ()
class pytest_agentic_fabric.mocking.FabricMocker

Convenience wrapper around pytest-mock for optional agent runtime tests.

mocker: pytest_mock.MockerFixture = None
mocked_modules: dict[str, types.ModuleType] = 'field(...)'
property MagicMock: Any

Return mocker.MagicMock for direct test customization.

property Mock: Any

Return mocker.Mock for direct test customization.

property patch: Any

Return mocker.patch for direct test customization.

property spy: Any

Return mocker.spy for direct test customization.

property stub: Any

Return mocker.stub for direct test customization.

mock_module(module_name: str) types.ModuleType

Install one fake import module and return it.

mock_modules(module_names: collections.abc.Iterable[str]) dict[str, types.ModuleType]

Install multiple fake import modules.

restore_modules() None

Restore fake modules and parent module attributes.

mock_crewai() dict[str, types.ModuleType]

Install fake CrewAI modules with common entry points.

mock_crewai_agent(**kwargs: Any) Any

Create a standalone CrewAI agent mock.

mock_crewai_task(**kwargs: Any) Any

Create a standalone CrewAI task mock.

mock_crewai_crew(result: str = 'Test result', **kwargs: Any) Any

Create a CrewAI crew mock whose kickoff returns a raw result.

patch_crewai_agent() Any

Patch crewai.Agent and return the patch mock.

patch_crewai_task() Any

Patch crewai.Task and return the patch mock.

patch_crewai_crew() Any

Patch crewai.Crew and return the patch mock.

patch_crewai_process() Any

Patch crewai.Process and return the patch mock.

patch_knowledge_source() Any

Patch or return the CrewAI text-file knowledge source mock.

mock_langgraph() dict[str, types.ModuleType]

Install fake LangGraph modules with common entry points.

patch_create_react_agent() Any

Patch or return langgraph.prebuilt.create_react_agent.

patch_chat_anthropic() Any

Patch or return langchain_anthropic.ChatAnthropic.

mock_langgraph_graph(result: str = 'Test response') Any

Create a LangGraph graph mock whose invoke returns one message.

mock_strands() dict[str, types.ModuleType]

Install fake Strands modules with common entry points.

patch_strands_agent() Any

Patch or return strands.Agent.

mock_strands_agent(result: str = 'Test response') Any

Create a Strands agent mock whose call returns text.

mock_all_frameworks() dict[str, types.ModuleType]

Install all supported optional runtime modules.

patch_get_llm(return_value: Any = None) Any

Patch agentic_fabric.config.llm.get_llm.

patch_discover_packages(packages: dict[str, Any] | None = None) Any

Patch agentic_fabric.core.discovery.discover_packages.

patch_get_fabric_agent_config(config: dict[str, Any] | None = None) Any

Patch agentic_fabric.core.discovery.get_fabric_agent_config.

patch_run_fabric_agent_auto(result: str = 'Test result') Any

Patch agentic_fabric.core.decomposer.run_fabric_agent_auto.

pytest_agentic_fabric.mocking.agentic_fabric_mocker(mocker: pytest_mock.MockerFixture) collections.abc.Generator[pytest_agentic_fabric.mocking.FabricMocker, None, None]

Provide FabricMocker for agentic-fabric tests.

pytest_agentic_fabric.mocking.fabric_mocker(mocker: pytest_mock.MockerFixture) collections.abc.Generator[pytest_agentic_fabric.mocking.FabricMocker, None, None]

Provide the concise FabricMocker fixture name.

pytest_agentic_fabric.mocking.mock_agentic_frameworks(mocker: pytest_mock.MockerFixture) collections.abc.Generator[dict[str, types.ModuleType], None, None]

Mock every optional agent runtime framework.

pytest_agentic_fabric.mocking.mock_crewai(mocker: pytest_mock.MockerFixture) collections.abc.Generator[dict[str, types.ModuleType], None, None]

Mock CrewAI modules only.

pytest_agentic_fabric.mocking.mock_langgraph(mocker: pytest_mock.MockerFixture) collections.abc.Generator[dict[str, types.ModuleType], None, None]

Mock LangGraph modules only.

pytest_agentic_fabric.mocking.mock_strands(mocker: pytest_mock.MockerFixture) collections.abc.Generator[dict[str, types.ModuleType], None, None]

Mock Strands modules only.