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_smoke.pytests/

"""Smoke tests for the public API."""

import re

from pytest_conversational import Conversation, Turn, __version__


def test_version_is_set():
    # Version is read from package metadata via importlib.metadata.
    # In a stale dev install it may lag pyproject.toml, so accept any
    # non-empty PEP 440 style string.
    assert isinstance(__version__, str)
    assert __version__
    assert re.match(r"^\d+\.\d+", __version__) or __version__.startswith("0.0.0+")


def test_empty_conversation_has_no_turns():
    convo = Conversation()
    assert convo.turns == []
    assert convo.last is None


def test_add_user_appends_turn():
    convo = Conversation()
    turn = convo.add_user("hello")
    assert turn.user == "hello"
    assert turn.bot == ""
    assert convo.last is turn
    assert len(convo.turns) == 1


def test_turn_metadata_isolated_per_instance():
    a = Turn(user="hi")
    b = Turn(user="hi")
    a.metadata["intent"] = "greet"
    assert b.metadata == {}


def test_fixture_provides_empty_conversation(pytester):
    pytester.makepyfile(
        """
        def test_smoke(conversation):
            assert conversation.turns == []
        """
    )
    result = pytester.runpytest()
    result.assert_outcomes(passed=1)

CHANGELOG.md

CONTRIBUTING.md

README.md

REFERENCE.md

SECURITY.md

SKILL.md

tessl.json

tile.json