Test chat bots, voice assistants, and IVR menus with pytest using a small Conversation object and a callable bot adapter. Use when the user wants to write rule-based assertions over multi-turn dialogue without bringing in an LLM dependency, when they have a chatbot reachable as a Python callable or HTTP webhook, when they need to keep per-conversation state across turns and assert on slot filling, when they want pytest-native fixtures and a printable transcript on failure, or when they mention voice-assistant testing, IVR menu testing, conversational AI testing, LLM bot testing (used as the target under test, not as the matcher), expect matchers for bot replies, or multi-turn dialogue tests.
99
100%
Does it follow best practices?
Impact
97%
1.56xAverage score across 3 eval scenarios
Passed
No known issues
"""Adapters module must import cleanly even when the optional ``httpx``
dependency is missing. The real ``http_webhook`` callable raises only
when the user actually invokes it.
"""
from __future__ import annotations
import importlib
import sys
def test_adapters_module_imports_without_eagerly_failing_on_httpx():
"""A user who installs pytest-conversational without ``[http]`` must
still be able to `import pytest_conversational.adapters`. The base
install ships no http_webhook scenarios, so any failure must surface
on first call, not at import time."""
# Force a fresh import to ensure the try/except path was exercised.
for mod in list(sys.modules):
if mod.startswith("pytest_conversational.adapters"):
del sys.modules[mod]
adapters = importlib.import_module("pytest_conversational.adapters")
assert "http_webhook" in adapters.__all__
assert callable(adapters.http_webhook)
def test_http_webhook_callable_exists_after_clean_reimport():
"""After fresh import, the attribute resolves to a callable (either
the real adapter when httpx is installed, or the import-stub when
httpx is missing). The caller must not have to guard on the
attribute's existence."""
for mod in list(sys.modules):
if mod.startswith("pytest_conversational.adapters"):
del sys.modules[mod]
from pytest_conversational.adapters import http_webhook
assert callable(http_webhook).tessl-plugin
evals
src
pytest_conversational
tests