mirror of
https://github.com/aiogram/aiogram.git
synced 2025-12-14 19:00:23 +00:00
new improved CallableMixin (#1357)
* optimized CallableMixin * changes and Sets * reformatted * Update CHANGES/1357.misc.rst Co-authored-by: Oleg A. <t0rr@mail.ru> --------- Co-authored-by: Oleg A. <t0rr@mail.ru>
This commit is contained in:
parent
9b5e462068
commit
e76f4c38ad
3 changed files with 17 additions and 13 deletions
|
|
@ -1,5 +1,5 @@
|
|||
import functools
|
||||
from typing import Any, Dict, Union
|
||||
from typing import Any, Dict, Union, Callable, Set
|
||||
|
||||
import pytest
|
||||
from magic_filter import F as A
|
||||
|
|
@ -61,9 +61,9 @@ class TestCallableMixin:
|
|||
pytest.param(SyncCallable(), {"self", "foo", "bar", "baz"}),
|
||||
],
|
||||
)
|
||||
def test_init_args_spec(self, callback, args):
|
||||
def test_init_args_spec(self, callback: Callable, args: Set[str]):
|
||||
obj = CallableMixin(callback)
|
||||
assert set(obj.spec.args) == args
|
||||
assert set(obj.params) == args
|
||||
|
||||
def test_init_decorated(self):
|
||||
def decorator(func):
|
||||
|
|
@ -85,9 +85,9 @@ class TestCallableMixin:
|
|||
obj1 = CallableMixin(callback1)
|
||||
obj2 = CallableMixin(callback2)
|
||||
|
||||
assert set(obj1.spec.args) == {"foo", "bar", "baz"}
|
||||
assert set(obj1.params) == {"foo", "bar", "baz"}
|
||||
assert obj1.callback == callback1
|
||||
assert set(obj2.spec.args) == {"foo", "bar", "baz"}
|
||||
assert set(obj2.params) == {"foo", "bar", "baz"}
|
||||
assert obj2.callback == callback2
|
||||
|
||||
@pytest.mark.parametrize(
|
||||
|
|
@ -124,7 +124,9 @@ class TestCallableMixin:
|
|||
),
|
||||
],
|
||||
)
|
||||
def test_prepare_kwargs(self, callback, kwargs, result):
|
||||
def test_prepare_kwargs(
|
||||
self, callback: Callable, kwargs: Dict[str, Any], result: Dict[str, Any]
|
||||
):
|
||||
obj = CallableMixin(callback)
|
||||
assert obj._prepare_kwargs(kwargs) == result
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue