mirror of
https://github.com/aiogram/aiogram.git
synced 2025-12-14 10:53:23 +00:00
#1370 added possibility to check X | None on Python >= 3.10
This commit is contained in:
parent
e17e3bc71c
commit
ce4e1a706d
2 changed files with 19 additions and 1 deletions
|
|
@ -1,3 +1,4 @@
|
|||
import sys
|
||||
from decimal import Decimal
|
||||
from enum import Enum, auto
|
||||
from fractions import Fraction
|
||||
|
|
@ -163,6 +164,16 @@ class TestCallbackData:
|
|||
|
||||
assert TgData.unpack("tg:123:") == TgData(chat_id=123, thread_id=None)
|
||||
|
||||
@pytest.mark.skipif(sys.version_info < (3, 10), reason="UnionType is added in Python 3.10")
|
||||
def test_unpack_optional_wo_default_union_type(self):
|
||||
"""Test CallbackData without default optional."""
|
||||
|
||||
class TgData(CallbackData, prefix="tg"):
|
||||
chat_id: int
|
||||
thread_id: int | None
|
||||
|
||||
assert TgData.unpack("tg:123:") == TgData(chat_id=123, thread_id=None)
|
||||
|
||||
def test_build_filter(self):
|
||||
filter_object = MyCallback.filter(F.foo == "test")
|
||||
assert isinstance(filter_object.rule, MagicFilter)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue