Skip to main content

aiogram_bot_tester

Your missing test toolkit for Telegram bots.

aiogram telegram status python PyPI Downloads

[!WARNING] This library is under active development. Its API is unstable and may contain frequent breaking changes between releases.

Installation

Stable version:

pip install aiogram_bot_tester

Latest development version:

pip install git+https://github.com/samedit66/aiogram-bot-tester.git

What's that?

aiogram_bot_tester is a lightweight way to test aiogram bots offline, without real Telegram API calls. It helps you simulate updates, check bot responses, and keep tests deterministic, so bot logic can be covered with confidence even when the conversation flow is complex.

Features

  • Fully offline testing — run bot scenarios without a Telegram token, network requests, or real API calls.
  • Real aiogram pipeline — updates pass through the actual dispatcher, routers, filters, middleware, and FSM machinery.
  • Conversation-first API — send messages and commands, start the bot, and tap reply or callback buttons by their visible labels.
  • Readable assertions — check message text, regular expressions, buttons, callback data, URLs, and complete keyboard layouts.
  • FSM support — assert the current state and inspect FSM data across multi-step conversation flows.
  • Flexible test setup — build a tester from reusable routers or an existing dispatcher, pass fake dependencies directly, and attach middleware when needed.

Quick example

import pytest
import aiogram
from aiogram import F
from aiogram.types import CallbackQuery, InlineKeyboardButton, InlineKeyboardMarkup, Message

from aiogram_bot_tester import BotTester

router = aiogram.Router()


@router.message(aiogram.filters.CommandStart())
async def cmd_start(message: Message) -> None:
    await message.answer(
        "Hello! Press Continue or send me your name.",
        reply_markup=InlineKeyboardMarkup(
            inline_keyboard=[
                [InlineKeyboardButton(text="Continue", callback_data="continue")]
            ]
        ),
    )


@router.message(F.text)
async def echo_name(message: Message) -> None:
    await message.answer(f"Nice to meet you, {message.text}!")


@router.callback_query(F.data == "continue")
async def on_continue(callback: CallbackQuery) -> None:
    await callback.message.answer("Please send your name.")


@pytest.mark.asyncio
async def test_flow() -> None:
    tester = BotTester.from_routers(router)

    response = await tester.start()
    response.assert_contains("Hello")
    response.assert_button("Continue")

    response = await tester.tap_button("Continue")
    response.assert_contains("Please send your name.")

    response = await tester.send_message("Bob")
    response.assert_contains("Nice to meet you, Bob!")

Download files

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

Source Distribution

aiogram_bot_tester-2.2.0.tar.gz (9.2 kB view details)

Uploaded Source

Built Distribution

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

aiogram_bot_tester-2.2.0-py3-none-any.whl (11.2 kB view details)

Uploaded Python 3

File details

Details for the file aiogram_bot_tester-2.2.0.tar.gz.

File metadata

  • Download URL: aiogram_bot_tester-2.2.0.tar.gz
  • Upload date:
  • Size: 9.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.11.24 {"installer":{"name":"uv","version":"0.11.24","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"macOS","version":null,"id":null,"libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}

File hashes

Hashes for aiogram_bot_tester-2.2.0.tar.gz
Algorithm Hash digest
SHA256 abeaf32121ef97eb832b1d3b0e76b7f234021f14ca65b05767bb31354ba3e805
MD5 9b3394e4fec034a16339c60b25de8357
BLAKE2b-256 bf5dffb775260c9fbc45f2fd04f4de4c222078c48a3a0428b8126f692d192792

See more details on using hashes here.

File details

Details for the file aiogram_bot_tester-2.2.0-py3-none-any.whl.

File metadata

  • Download URL: aiogram_bot_tester-2.2.0-py3-none-any.whl
  • Upload date:
  • Size: 11.2 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.11.24 {"installer":{"name":"uv","version":"0.11.24","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"macOS","version":null,"id":null,"libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}

File hashes

Hashes for aiogram_bot_tester-2.2.0-py3-none-any.whl
Algorithm Hash digest
SHA256 8d054c2c85d29546355338643ec930f6dee6bc0869b310cde3a73ae12d4d0303
MD5 239aeceb1de2dfbd5e30ba37438dcc54
BLAKE2b-256 87de2094ff9812c042f1ccb7de21e9d6c3f67096d376fc5e66a4ead72a2d2f8f

See more details on using hashes here.

Release history Release notifications | RSS feed

This release

2.2.0 This release

2 files

2.1.0

2 files

2.0.0

2 files

1.0.1

2 files

1.0.0

2 files

0.4.0

2 files

0.3.0

2 files

0.2.0

2 files

0.1.0

2 files

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page