aiogram/tests/test_utils/test_dataclass.py
Alex Root Junior ec7da0f678
Migrate from Black to Ruff (#1750)
* Migrate from Black to Ruff and reformat code with enabling additional linter checks

* Add changelog for migration to Ruff as formatter and linter

* Add type ignores for specific attributes and replace tuple with set for chat type check

* Remove file from another changes
2026-01-04 21:34:08 +02:00

48 lines
1.2 KiB
Python

from unittest.mock import patch
import pytest
from aiogram.utils.dataclass import dataclass_kwargs
ALL_VERSIONS = {
"init": True,
"repr": True,
"eq": True,
"order": True,
"unsafe_hash": True,
"frozen": True,
}
ADDED_IN_3_10 = {"match_args": True, "kw_only": True, "slots": True}
ADDED_IN_3_11 = {"weakref_slot": True}
PY_310 = {**ALL_VERSIONS, **ADDED_IN_3_10}
PY_311 = {**PY_310, **ADDED_IN_3_11}
LATEST_PY = PY_311
class TestDataclassKwargs:
@pytest.mark.parametrize(
"py_version,expected",
[
((3, 10, 2), PY_310),
((3, 11, 0), PY_311),
((4, 13, 0), LATEST_PY),
],
)
def test_dataclass_kwargs(self, py_version, expected):
with patch("sys.version_info", py_version):
assert (
dataclass_kwargs(
init=True,
repr=True,
eq=True,
order=True,
unsafe_hash=True,
frozen=True,
match_args=True,
kw_only=True,
slots=True,
weakref_slot=True,
)
== expected
)