@@ -401,7 +401,7 @@ async def test_handler_invoked(
401401 handler ,
402402 handler_checker ,
403403 inbox ,
404- async_wait_for ,
404+ async_poll_until ,
405405 ):
406406 # Set the handler
407407 setattr (handler_manager , handler_name , handler )
@@ -412,7 +412,7 @@ async def test_handler_invoked(
412412 # Add an item to the associated inbox, triggering the handler
413413 mock_obj = mocker .MagicMock ()
414414 inbox .put (mock_obj )
415- await async_wait_for (lambda : handler_checker .handler_called )
415+ await async_poll_until (lambda : handler_checker .handler_called )
416416
417417 # Handler has been called with the item from the inbox
418418 assert handler_checker .handler_called is True
@@ -429,7 +429,7 @@ async def test_handler_invoked_multiple(
429429 handler ,
430430 handler_checker ,
431431 inbox ,
432- async_wait_for ,
432+ async_poll_until ,
433433 ):
434434 # Set the handler
435435 setattr (handler_manager , handler_name , handler )
@@ -439,7 +439,7 @@ async def test_handler_invoked_multiple(
439439 # Add 5 items to the associated inbox, triggering the handler
440440 for _ in range (5 ):
441441 inbox .put (mocker .MagicMock ())
442- await async_wait_for (lambda : handler_checker .handler_call_count >= 5 )
442+ await async_poll_until (lambda : handler_checker .handler_call_count >= 5 )
443443
444444 # Handler has been called 5 times
445445 assert handler_checker .handler_call_count == 5
@@ -525,7 +525,7 @@ def tracked_put(item):
525525 "Sends a HandlerManagerException to the background exception handler if any exception is raised during its invocation"
526526 )
527527 async def test_exception_in_handler (
528- self , mocker , handler_name , handler_manager , inbox , arbitrary_exception , async_wait_for
528+ self , mocker , handler_name , handler_manager , inbox , arbitrary_exception , async_poll_until
529529 ):
530530 # NOTE: this test tests both coroutines and functions without the need for parametrization
531531 background_exc_spy = mocker .spy (handle_exceptions , "handle_background_exception" )
@@ -542,7 +542,7 @@ async def coro_handler(arg):
542542 assert background_exc_spy .call_count == 0
543543 # Add an item to corresponding inbox, triggering the handler
544544 inbox .put (mocker .MagicMock ())
545- await async_wait_for (lambda : background_exc_spy .call_count >= 1 )
545+ await async_poll_until (lambda : background_exc_spy .call_count >= 1 )
546546 # Background exception handler was called
547547 assert background_exc_spy .call_count == 1
548548 e = background_exc_spy .call_args [0 ][0 ]
@@ -558,7 +558,7 @@ async def coro_handler(arg):
558558 assert background_exc_spy .call_count == 0
559559 # Add an item to corresponding inbox, triggering the handler
560560 inbox .put (mocker .MagicMock ())
561- await async_wait_for (lambda : background_exc_spy .call_count >= 1 )
561+ await async_poll_until (lambda : background_exc_spy .call_count >= 1 )
562562 # Background exception handler was called
563563 assert background_exc_spy .call_count == 1
564564 e = background_exc_spy .call_args [0 ][0 ]
@@ -569,7 +569,7 @@ async def coro_handler(arg):
569569 "Can be updated with a new value that the corresponding handler runner will immediately begin using for handler invocations instead"
570570 )
571571 async def test_handler_update_handler (
572- self , mocker , handler_name , handler_manager , inbox , async_wait_for
572+ self , mocker , handler_name , handler_manager , inbox , async_poll_until
573573 ):
574574 # NOTE: this test tests both coroutines and functions without the need for parametrization
575575 mock_handler = mocker .MagicMock ()
@@ -585,19 +585,19 @@ def handler1(arg):
585585 setattr (handler_manager , handler_name , handler1 )
586586
587587 inbox .put (mocker .MagicMock ())
588- await async_wait_for (lambda : getattr (handler_manager , handler_name ) is handler2 )
588+ await async_poll_until (lambda : getattr (handler_manager , handler_name ) is handler2 )
589589 # The set handler (handler1) has been replaced with a new handler (handler2)
590590 assert getattr (handler_manager , handler_name ) is not handler1
591591 assert getattr (handler_manager , handler_name ) is handler2
592592 # Add a new item to the inbox
593593 inbox .put (mocker .MagicMock ())
594- await async_wait_for (lambda : getattr (handler_manager , handler_name ) is mock_handler )
594+ await async_poll_until (lambda : getattr (handler_manager , handler_name ) is mock_handler )
595595 # The set handler (handler2) has now been replaced by a mock handler
596596 assert getattr (handler_manager , handler_name ) is not handler2
597597 assert getattr (handler_manager , handler_name ) is mock_handler
598598 # Add a new item to the inbox
599599 inbox .put (mocker .MagicMock ())
600- await async_wait_for (lambda : mock_handler .call_count >= 1 )
600+ await async_poll_until (lambda : mock_handler .call_count >= 1 )
601601 # The mock was now called
602602 assert getattr (handler_manager , handler_name ).call_count == 1
603603
@@ -680,7 +680,7 @@ async def test_handler_invoked(
680680 handler ,
681681 inbox ,
682682 event ,
683- async_wait_for ,
683+ async_poll_until ,
684684 ):
685685 # Set the handler
686686 setattr (handler_manager , handler_name , handler )
@@ -689,7 +689,7 @@ async def test_handler_invoked(
689689
690690 # Add the event to the client inbox
691691 inbox .put (event )
692- await async_wait_for (lambda : handler_checker .handler_call_count >= 1 )
692+ await async_poll_until (lambda : handler_checker .handler_call_count >= 1 )
693693
694694 # Handler has been called with the arguments from the event
695695 assert handler_checker .handler_call_count == 1
@@ -698,7 +698,7 @@ async def test_handler_invoked(
698698 # Add a non-matching event ot the client event inbox
699699 non_matching_event = client_event .ClientEvent ("NON_MATCHING_EVENT" )
700700 inbox .put (non_matching_event )
701- await async_wait_for (inbox .empty )
701+ await async_poll_until (inbox .empty )
702702
703703 # Handler has not been called again
704704 assert handler_checker .handler_call_count == 1
@@ -714,7 +714,7 @@ async def test_handler_invoked_multiple(
714714 handler_checker ,
715715 inbox ,
716716 event ,
717- async_wait_for ,
717+ async_poll_until ,
718718 ):
719719 # Set the handler
720720 setattr (handler_manager , handler_name , handler )
@@ -724,7 +724,7 @@ async def test_handler_invoked_multiple(
724724 # Add 5 items to the corresponding inbox, triggering the handler
725725 for _ in range (5 ):
726726 inbox .put (event )
727- await async_wait_for (lambda : handler_checker .handler_call_count >= 5 )
727+ await async_poll_until (lambda : handler_checker .handler_call_count >= 5 )
728728
729729 # Handler has been called 5 times
730730 assert handler_checker .handler_call_count == 5
@@ -740,7 +740,7 @@ async def test_exception_in_handler(
740740 inbox ,
741741 event ,
742742 arbitrary_exception ,
743- async_wait_for ,
743+ async_poll_until ,
744744 ):
745745 # NOTE: this test tests both coroutines and functions without the need for parametrization
746746 background_exc_spy = mocker .spy (handle_exceptions , "handle_background_exception" )
@@ -757,7 +757,7 @@ async def coro_handler(*args):
757757 assert background_exc_spy .call_count == 0
758758 # Add an item to corresponding inbox, triggering the handler
759759 inbox .put (event )
760- await async_wait_for (lambda : background_exc_spy .call_count >= 1 )
760+ await async_poll_until (lambda : background_exc_spy .call_count >= 1 )
761761 # Background exception handler was called
762762 assert background_exc_spy .call_count == 1
763763 e = background_exc_spy .call_args [0 ][0 ]
@@ -773,7 +773,7 @@ async def coro_handler(*args):
773773 assert background_exc_spy .call_count == 0
774774 # Add an item to corresponding inbox, triggering the handler
775775 inbox .put (event )
776- await async_wait_for (lambda : background_exc_spy .call_count >= 1 )
776+ await async_poll_until (lambda : background_exc_spy .call_count >= 1 )
777777 # Background exception handler was called
778778 assert background_exc_spy .call_count == 1
779779 e = background_exc_spy .call_args [0 ][0 ]
@@ -784,7 +784,7 @@ async def coro_handler(*args):
784784 "Can be updated with a new value that the corresponding handler runner will immediately begin using for handler invocations instead"
785785 )
786786 async def test_handler_update_handler (
787- self , mocker , handler_name , handler_manager , inbox , event , async_wait_for
787+ self , mocker , handler_name , handler_manager , inbox , event , async_poll_until
788788 ):
789789 # NOTE: this test tests both coroutines and functions without the need for parametrization
790790 mock_handler = mocker .MagicMock ()
@@ -800,19 +800,19 @@ def handler1(*args):
800800 setattr (handler_manager , handler_name , handler1 )
801801
802802 inbox .put (event )
803- await async_wait_for (lambda : getattr (handler_manager , handler_name ) is handler2 )
803+ await async_poll_until (lambda : getattr (handler_manager , handler_name ) is handler2 )
804804 # The set handler (handler1) has been replaced with a new handler (handler2)
805805 assert getattr (handler_manager , handler_name ) is not handler1
806806 assert getattr (handler_manager , handler_name ) is handler2
807807 # Add a new item to the inbox
808808 inbox .put (event )
809- await async_wait_for (lambda : getattr (handler_manager , handler_name ) is mock_handler )
809+ await async_poll_until (lambda : getattr (handler_manager , handler_name ) is mock_handler )
810810 # The set handler (handler2) has now been replaced by a mock handler
811811 assert getattr (handler_manager , handler_name ) is not handler2
812812 assert getattr (handler_manager , handler_name ) is mock_handler
813813 # Add a new item to the inbox
814814 inbox .put (event )
815- await async_wait_for (lambda : mock_handler .call_count >= 1 )
815+ await async_poll_until (lambda : mock_handler .call_count >= 1 )
816816 # The mock was now called
817817 assert getattr (handler_manager , handler_name ).call_count == 1
818818
0 commit comments