CtrlK
BlogDocsLog inGet started
Tessl Logo

golikovichev/pytest-conversational

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

1.56x
Quality

100%

Does it follow best practices?

Impact

97%

1.56x

Average score across 3 eval scenarios

SecuritybySnyk

Passed

No known issues

Overview
Quality
Evals
Security
Files

test_faq_bot.pyexamples/

"""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")

CHANGELOG.md

CONTRIBUTING.md

README.md

REFERENCE.md

SECURITY.md

SKILL.md

tessl.json

tile.json