Skip to main content

aiogram_bot_tester

Your missing test toolkit for Telegram bots.

aiogram telegram status python PyPI Downloads

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

Metadata

Release files for aiogram_bot_tester 2.2.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for aiogram_bot_tester 2.2.0
File Size Uploaded
aiogram_bot_tester-2.2.0.tar.gz 9.2 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for aiogram_bot_tester 2.2.0
File Interpreter ABI Platform
aiogram_bot_tester-2.2.0-py3-none-any.whl Python 3 none any Details

Total release size: 20.4 kB

Release files / aiogram_bot_tester-2.2.0.tar.gz

Download URL aiogram_bot_tester-2.2.0.tar.gz
Size 9.2 kB
Tags Source
SHA-256 checksum
How to use checksums
abeaf32121ef97eb832b1d3b0e76b7f234021f14ca65b05767bb31354ba3e805
BLAKE2b-256 checksum
How to use checksums
bf5dffb775260c9fbc45f2fd04f4de4c222078c48a3a0428b8126f692d192792
Upload date
Uploaded using Trusted Publishing?
What is 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}

Release files / aiogram_bot_tester-2.2.0-py3-none-any.whl

Download URL aiogram_bot_tester-2.2.0-py3-none-any.whl
Size 11.2 kB
Tags Python 3
SHA-256 checksum
How to use checksums
8d054c2c85d29546355338643ec930f6dee6bc0869b310cde3a73ae12d4d0303
BLAKE2b-256 checksum
How to use checksums
87de2094ff9812c042f1ccb7de21e9d6c3f67096d376fc5e66a4ead72a2d2f8f
Upload date
Uploaded using Trusted Publishing?
What is 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}

Release history Release notifications | RSS feed

This release

2.2.0 This release

2 release files

2.1.0

2 release files

2.0.0

2 release files

1.0.1

2 release files

1.0.0

2 release files

0.4.0

2 release files

0.3.0

2 release files

0.2.0

2 release files

0.1.0

2 release 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