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
Your team has built a context-aware trivia bot that adjusts its behavior based on the conversation history. The bot is smart enough to detect when a user has already asked about a particular category earlier in the session, and it tailors follow-up responses accordingly. It also enforces a rule: if a user asks a question about a banned topic, it raises a custom BannedTopicError exception rather than returning a reply.
A QA engineer needs a pytest test suite that covers the bot's history-aware behavior and its error handling. The engineer wants to verify: (a) that when conversation history is pre-loaded with some prior exchanges, the bot correctly reads that history and adjusts its next reply; (b) that when the bot raises BannedTopicError, the exception travels out of the turn-driving call unmodified so tests can catch it, and that the conversation remains inspectable afterwards — the failed turn should still be accessible; (c) that the full dialogue can be rendered as plain text for use in diagnostic output.
The bot adapter is a pure Python callable — no external services or API keys are needed.
Produce the following files in your working directory:
trivia_bot.py — the bot adapter implementing the context-aware trivia logic and the BannedTopicError exception classtest_trivia_bot.py — the pytest test suite covering the three scenarios described aboveresults.txt — the output of running pytest -v test_trivia_bot.py, captured to this fileAll tests should pass. The results.txt file should contain the full pytest output including individual test names and their pass/fail status.
.tessl-plugin
evals
src
pytest_conversational
tests