From 4484323c4de1d2c91eab44d6b96954dd319aa375 Mon Sep 17 00:00:00 2001 From: PasNA6713 Date: Mon, 24 Jan 2022 22:56:06 +0300 Subject: [PATCH] use global pytest.mark.asyncio instead decorator --- examples/finite_state_machine_signals.py | 2 +- tests/test_states_group_navigation.py | 12 +++--------- 2 files changed, 4 insertions(+), 10 deletions(-) diff --git a/examples/finite_state_machine_signals.py b/examples/finite_state_machine_signals.py index d8442855..b05b38b0 100644 --- a/examples/finite_state_machine_signals.py +++ b/examples/finite_state_machine_signals.py @@ -70,7 +70,7 @@ async def gender_pre_set(context: FSMContext, old_state: str, new_state: str): # You can use pre_finish decorator to call decorated functions before state group will be finished @Form.pre_finish -async def form_post_finish(context: FSMContext, old_state: str): +async def form_pre_finish(context: FSMContext, old_state: str): async with context.proxy() as data: markup = types.ReplyKeyboardRemove() diff --git a/tests/test_states_group_navigation.py b/tests/test_states_group_navigation.py index 92339b46..b4241ff1 100644 --- a/tests/test_states_group_navigation.py +++ b/tests/test_states_group_navigation.py @@ -4,6 +4,8 @@ from aiogram.contrib.fsm_storage.memory import MemoryStorage from aiogram.dispatcher import FSMContext from aiogram.dispatcher.filters.state import StatesGroup, State +pytestmark = pytest.mark.asyncio + class FakeDispatcher: context = FSMContext(MemoryStorage(), chat=1, user=1) @@ -26,7 +28,7 @@ async def reset_dispatcher(): FakeDispatcher.reset() context = FakeDispatcher.get_current().current_state() current_state = await context.get_state() - assert current_state == None + assert current_state == None yield FakeDispatcher @@ -36,47 +38,39 @@ class MyGroup(StatesGroup, dispatcher=FakeDispatcher()): class TestNavigation: - @pytest.mark.asyncio async def test_first(self, reset_dispatcher): state = await MyGroup.first() assert state == 'MyGroup:state_1' - @pytest.mark.asyncio async def test_last(self, reset_dispatcher): state = await MyGroup.last() assert state == 'MyGroup:state_2' class TestNext: - @pytest.mark.asyncio async def test_next_from_none(self, reset_dispatcher): state = await MyGroup.next() assert state == 'MyGroup:state_1' - @pytest.mark.asyncio async def test_next_from_the_first_state(self, reset_dispatcher): await MyGroup.state_1.set() state = await MyGroup.next() assert state == 'MyGroup:state_2' - @pytest.mark.asyncio async def test_next_from_the_last_state(self, reset_dispatcher): await MyGroup.last() state = await MyGroup.next() assert state == None class TestPrevious: - @pytest.mark.asyncio async def test_previous_from_none(self, reset_dispatcher): state = await MyGroup.previous() assert state == 'MyGroup:state_1' - @pytest.mark.asyncio async def test_previous_from_the_first_state(self, reset_dispatcher): await MyGroup.first() state = await MyGroup.previous() assert state == None - @pytest.mark.asyncio async def test_previous_from_the_last_state(self, reset_dispatcher): await MyGroup.state_2.set() state = await MyGroup.previous()