mirror of
https://github.com/aiogram/aiogram.git
synced 2025-12-06 07:50:32 +00:00
Upgrade architecture + 5.0 Bot API (#469) * Moved `methods`, `types` and `client` to root package * Removed update handler from routers to dispatcher * Reworked events propagation mechanism to handlers * Reworked inner middlewares logic (very small change) * Updated to Bot API 5.0 * Initial migration from MkDocs to Sphinx + config for readthedocs
28 lines
679 B
Python
28 lines
679 B
Python
from contextlib import contextmanager
|
|
from typing import Type
|
|
|
|
import pytest
|
|
from packaging import version
|
|
|
|
import aiogram
|
|
|
|
|
|
@contextmanager
|
|
def check_deprecated(
|
|
max_version: str,
|
|
exception: Type[Exception],
|
|
warning: Type[Warning] = DeprecationWarning,
|
|
) -> None:
|
|
"""
|
|
Should be used for modules that are being deprecated or already removed from aiogram
|
|
"""
|
|
|
|
parsed_max_version = version.parse(max_version)
|
|
current_version = version.parse(aiogram.__version__)
|
|
|
|
if parsed_max_version <= current_version:
|
|
with pytest.raises(exception):
|
|
yield
|
|
else:
|
|
with pytest.warns(warning, match=max_version):
|
|
yield
|