Skip to main content
Yanked

This release has been yanked by its maintainers, and will be ignored by installers, except when explicitly specified.
Consider using release 1.5.0 instead.
Reason given by maintainers: Use 1.5.0 instead

Microsoft Agents Testing

PyPI version

Testing utilities for the Microsoft 365 Agents SDK for Python. This package provides an in-memory channel adapter, fluent conversation assertions, and a mock user-token client so agent behavior can be tested without a live channel or token service.

Release Notes

Version Date Release Notes
1.5.0 2026-08-26 1.5.0 Release Notes

Features

  • TestAdapter runs activities through the normal middleware and agent pipeline while capturing outgoing activities in memory.
  • TestFlow provides fluent helpers for sending activities and asserting replies in order.
  • MockUserTokenClient supports stored tokens, magic codes, sign-out, token status, and token-exchange scenarios.
  • Async-first APIs work with the SDK's standard TurnContext and ChannelAdapter abstractions.

Installation

pip install microsoft-agents-testing

Quick Start

import pytest

from microsoft_agents.hosting.core import TurnContext
from microsoft_agents.testing import TestAdapter, TestFlow


@pytest.mark.asyncio
async def test_echo_agent():
    adapter = TestAdapter()

    async def on_turn(context: TurnContext):
        await context.send_activity(f"Echo: {context.activity.text}")

    await (
        TestFlow(adapter, on_turn)
        .send("hello")
        .assert_reply("Echo: hello")
        .assert_no_more_replies()
        .start_test()
    )

Reply Assertions

Replies can be matched by exact text, partial text, activity properties, or a custom synchronous or asynchronous validator:

from microsoft_agents.activity import Activity, ActivityTypes


def validate_reply(reply: Activity):
    assert reply.type == ActivityTypes.message
    assert reply.text is not None
    assert reply.text.startswith("Hello")


await (
    TestFlow(adapter, on_turn)
    .send("hi")
    .assert_reply_contains("Hello")
    .send("details")
    .assert_reply(validate_reply)
    .start_test()
)

TestFlow also supports conversation updates, typing indicators, delays, mixed activity transcripts, and configurable reply timeouts.

Testing OAuth Flows

TestAdapter uses MockUserTokenClient by default. Add a token to test an already-authenticated user:

adapter = TestAdapter(channel_id="msteams")

adapter.add_user_token(
    connection_name="my-connection",
    channel_id="msteams",
    user_id="user1",
    token="test-token",
)

Token exchange can be configured in the same way:

adapter.add_exchangeable_token(
    connection_name="my-connection",
    channel_id="msteams",
    user_id="user1",
    exchangeable_item="exchange-token",
    token="exchanged-token",
)

These tokens are stored only in memory and are intended exclusively for tests.

Scope

The adapter models the turn-processing boundary needed by unit tests. It does not contact Connector Service, create real proactive conversations, or emulate channel-specific delivery behavior.

Related Packages

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

microsoft_agents_testing-1.6.0.tar.gz (16.1 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

microsoft_agents_testing-1.6.0-py3-none-any.whl (17.8 kB view details)

Uploaded Python 3

File details

Details for the file microsoft_agents_testing-1.6.0.tar.gz.

File metadata

File hashes

Hashes for microsoft_agents_testing-1.6.0.tar.gz
Algorithm Hash digest
SHA256 3368f4140b112fcecd485f5a2918d784639e8016663a2d3b65e0474739ec1ead
MD5 c750b03244bc87b2d929e9128d62aaaf
BLAKE2b-256 22b3f544765736796ba44f5c52b03e7358f261a16d38b0cfcb29ccda10c66c0c

See more details on using hashes here.

File details

Details for the file microsoft_agents_testing-1.6.0-py3-none-any.whl.

File metadata

File hashes

Hashes for microsoft_agents_testing-1.6.0-py3-none-any.whl
Algorithm Hash digest
SHA256 4024ee9d478385e45e646e7f2792a011763840b2a0462c27f3ca0341c57e06a0
MD5 42a1c6a2e422ecb64f47a41391311ebe
BLAKE2b-256 f576d070e9906e123f97f50ca6344fe8006ab8fb6ea76b79785e0e27b80b5650

See more details on using hashes here.

Release history Release notifications | RSS feed

This release

1.6.0 This release

2 files

1.5.0

2 files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page