@@ -413,7 +413,7 @@ async def test_handler_invoked(
413413 mock_obj = mocker .MagicMock ()
414414 inbox .put (mock_obj )
415415 # Wait for the handler invocation to complete
416- await async_poll_until (lambda : handler_checker .handler_called )
416+ await async_poll_until (lambda : handler_checker .handler_called , timeout = 5 )
417417
418418 # Handler has been called with the item from the inbox
419419 assert handler_checker .handler_called is True
@@ -441,7 +441,7 @@ async def test_handler_invoked_multiple(
441441 for _ in range (5 ):
442442 inbox .put (mocker .MagicMock ())
443443 # Wait for all handler invocations to complete
444- await async_poll_until (lambda : handler_checker .handler_call_count >= 5 )
444+ await async_poll_until (lambda : handler_checker .handler_call_count >= 5 , timeout = 5 )
445445
446446 # Handler has been called 5 times
447447 assert handler_checker .handler_call_count == 5
@@ -550,7 +550,7 @@ async def coro_handler(arg):
550550 # Add an item to corresponding inbox, triggering the handler
551551 inbox .put (mocker .MagicMock ())
552552 # Wait for the background exception handler to be called
553- await async_poll_until (lambda : background_exc_spy .call_count >= 1 )
553+ await async_poll_until (lambda : background_exc_spy .call_count >= 1 , timeout = 5 )
554554 # Background exception handler was called
555555 assert background_exc_spy .call_count == 1
556556 e = background_exc_spy .call_args [0 ][0 ]
@@ -567,7 +567,7 @@ async def coro_handler(arg):
567567 # Add an item to corresponding inbox, triggering the handler
568568 inbox .put (mocker .MagicMock ())
569569 # Wait for the background exception handler to be called
570- await async_poll_until (lambda : background_exc_spy .call_count >= 1 )
570+ await async_poll_until (lambda : background_exc_spy .call_count >= 1 , timeout = 5 )
571571 # Background exception handler was called
572572 assert background_exc_spy .call_count == 1
573573 e = background_exc_spy .call_args [0 ][0 ]
@@ -595,21 +595,25 @@ def handler1(arg):
595595
596596 inbox .put (mocker .MagicMock ())
597597 # Wait for handler1 to replace itself with handler2
598- await async_poll_until (lambda : getattr (handler_manager , handler_name ) is handler2 )
598+ await async_poll_until (
599+ lambda : getattr (handler_manager , handler_name ) is handler2 , timeout = 5
600+ )
599601 # The set handler (handler1) has been replaced with a new handler (handler2)
600602 assert getattr (handler_manager , handler_name ) is not handler1
601603 assert getattr (handler_manager , handler_name ) is handler2
602604 # Add a new item to the inbox
603605 inbox .put (mocker .MagicMock ())
604606 # Wait for handler2 to replace itself with the mock
605- await async_poll_until (lambda : getattr (handler_manager , handler_name ) is mock_handler )
607+ await async_poll_until (
608+ lambda : getattr (handler_manager , handler_name ) is mock_handler , timeout = 5
609+ )
606610 # The set handler (handler2) has now been replaced by a mock handler
607611 assert getattr (handler_manager , handler_name ) is not handler2
608612 assert getattr (handler_manager , handler_name ) is mock_handler
609613 # Add a new item to the inbox
610614 inbox .put (mocker .MagicMock ())
611615 # Wait for the mock handler invocation to complete
612- await async_poll_until (lambda : mock_handler .call_count >= 1 )
616+ await async_poll_until (lambda : mock_handler .call_count >= 1 , timeout = 5 )
613617 # The mock was now called
614618 assert getattr (handler_manager , handler_name ).call_count == 1
615619
@@ -702,7 +706,7 @@ async def test_handler_invoked(
702706 # Add the event to the client inbox
703707 inbox .put (event )
704708 # Wait for the handler invocation to complete
705- await async_poll_until (lambda : handler_checker .handler_call_count >= 1 )
709+ await async_poll_until (lambda : handler_checker .handler_call_count >= 1 , timeout = 5 )
706710
707711 # Handler has been called with the arguments from the event
708712 assert handler_checker .handler_call_count == 1
@@ -712,7 +716,7 @@ async def test_handler_invoked(
712716 non_matching_event = client_event .ClientEvent ("NON_MATCHING_EVENT" )
713717 inbox .put (non_matching_event )
714718 # Wait for the runner to consume the non-matching event
715- await async_poll_until (inbox .empty )
719+ await async_poll_until (inbox .empty , timeout = 5 )
716720
717721 # Handler has not been called again
718722 assert handler_checker .handler_call_count == 1
@@ -739,7 +743,7 @@ async def test_handler_invoked_multiple(
739743 for _ in range (5 ):
740744 inbox .put (event )
741745 # Wait for all handler invocations to complete
742- await async_poll_until (lambda : handler_checker .handler_call_count >= 5 )
746+ await async_poll_until (lambda : handler_checker .handler_call_count >= 5 , timeout = 5 )
743747
744748 # Handler has been called 5 times
745749 assert handler_checker .handler_call_count == 5
@@ -773,7 +777,7 @@ async def coro_handler(*args):
773777 # Add an item to corresponding inbox, triggering the handler
774778 inbox .put (event )
775779 # Wait for the background exception handler to be called
776- await async_poll_until (lambda : background_exc_spy .call_count >= 1 )
780+ await async_poll_until (lambda : background_exc_spy .call_count >= 1 , timeout = 5 )
777781 # Background exception handler was called
778782 assert background_exc_spy .call_count == 1
779783 e = background_exc_spy .call_args [0 ][0 ]
@@ -790,7 +794,7 @@ async def coro_handler(*args):
790794 # Add an item to corresponding inbox, triggering the handler
791795 inbox .put (event )
792796 # Wait for the background exception handler to be called
793- await async_poll_until (lambda : background_exc_spy .call_count >= 1 )
797+ await async_poll_until (lambda : background_exc_spy .call_count >= 1 , timeout = 5 )
794798 # Background exception handler was called
795799 assert background_exc_spy .call_count == 1
796800 e = background_exc_spy .call_args [0 ][0 ]
@@ -818,21 +822,25 @@ def handler1(*args):
818822
819823 inbox .put (event )
820824 # Wait for handler1 to replace itself with handler2
821- await async_poll_until (lambda : getattr (handler_manager , handler_name ) is handler2 )
825+ await async_poll_until (
826+ lambda : getattr (handler_manager , handler_name ) is handler2 , timeout = 5
827+ )
822828 # The set handler (handler1) has been replaced with a new handler (handler2)
823829 assert getattr (handler_manager , handler_name ) is not handler1
824830 assert getattr (handler_manager , handler_name ) is handler2
825831 # Add a new item to the inbox
826832 inbox .put (event )
827833 # Wait for handler2 to replace itself with the mock
828- await async_poll_until (lambda : getattr (handler_manager , handler_name ) is mock_handler )
834+ await async_poll_until (
835+ lambda : getattr (handler_manager , handler_name ) is mock_handler , timeout = 5
836+ )
829837 # The set handler (handler2) has now been replaced by a mock handler
830838 assert getattr (handler_manager , handler_name ) is not handler2
831839 assert getattr (handler_manager , handler_name ) is mock_handler
832840 # Add a new item to the inbox
833841 inbox .put (event )
834842 # Wait for the mock handler invocation to complete
835- await async_poll_until (lambda : mock_handler .call_count >= 1 )
843+ await async_poll_until (lambda : mock_handler .call_count >= 1 , timeout = 5 )
836844 # The mock was now called
837845 assert getattr (handler_manager , handler_name ).call_count == 1
838846
0 commit comments