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
"""FAQ bot example.
Shows how to use ``expect.one_of`` and ``expect.regex`` against a bot that
returns canned answers based on keywords in the user message.
"""
from pytest_conversational import expect
def faq_bot(text, convo):
text = text.lower()
if "hi" in text or "hello" in text:
return "Hello! How can I help you today?"
if "hours" in text:
return "We are open 9am-5pm, Monday to Friday."
if "refund" in text:
return "Refunds take 5-7 business days to process."
return "I'm sorry, I don't have an answer for that."
def test_greeting_variants(conversation_factory):
convo = conversation_factory(bot=faq_bot)
convo.say("Hi there")
expect.one_of(convo.last.bot, ["Hello! How can I help you today?", "Hi!"])
def test_store_hours(conversation_factory):
convo = conversation_factory(bot=faq_bot)
convo.say("What are your hours?")
expect.regex(convo.last.bot, r"\d[ap]m-\d[ap]m")
expect.contains(convo.last.bot, "Monday").tessl-plugin
evals
src
pytest_conversational
tests