@@ -554,11 +554,18 @@ def on_task_setup(self, task):
554554
555555@pytest .fixture
556556def make_async_exec_ctx (temp_runtime ):
557+ tmprt = None
558+
557559 def _make_async_exec_ctx (max_jobs ):
558- yield from temp_runtime (fixtures .TEST_CONFIG_FILE , 'generic' ,
559- {'systems/partitions/max_jobs' : max_jobs })
560+ nonlocal tmprt
561+ tmprt = temp_runtime (fixtures .TEST_CONFIG_FILE , 'generic' ,
562+ {'systems/partitions/max_jobs' : max_jobs })
563+ next (tmprt )
564+
565+ yield _make_async_exec_ctx
560566
561- return _make_async_exec_ctx
567+ with contextlib .suppress (StopIteration ):
568+ next (tmprt )
562569
563570
564571@pytest .fixture
@@ -592,8 +599,7 @@ def test_concurrency_unlimited(async_runner, make_cases, make_async_exec_ctx):
592599 num_checks = 3
593600
594601 # Trigger evaluation of the execution context
595- ctx = make_async_exec_ctx (num_checks )
596- next (ctx )
602+ make_async_exec_ctx (max_jobs = num_checks )
597603
598604 runner , monitor = async_runner
599605 runner .runall (make_cases ([SleepCheck (.5 ) for i in range (num_checks )]))
@@ -620,8 +626,7 @@ def test_concurrency_unlimited(async_runner, make_cases, make_async_exec_ctx):
620626def test_concurrency_limited (async_runner , make_cases , make_async_exec_ctx ):
621627 # The number of checks must be <= 2*max_jobs.
622628 num_checks , max_jobs = 5 , 3
623- ctx = make_async_exec_ctx (max_jobs )
624- next (ctx )
629+ make_async_exec_ctx (max_jobs )
625630
626631 runner , monitor = async_runner
627632 runner .runall (make_cases ([SleepCheck (.5 ) for i in range (num_checks )]))
@@ -662,8 +667,7 @@ def test_concurrency_limited(async_runner, make_cases, make_async_exec_ctx):
662667
663668def test_concurrency_none (async_runner , make_cases , make_async_exec_ctx ):
664669 num_checks = 3
665- ctx = make_async_exec_ctx (1 )
666- next (ctx )
670+ make_async_exec_ctx (max_jobs = 1 )
667671
668672 runner , monitor = async_runner
669673 runner .runall (make_cases ([SleepCheck (.5 ) for i in range (num_checks )]))
@@ -703,9 +707,7 @@ def assert_interrupted_run(runner):
703707
704708def test_kbd_interrupt_in_wait_with_concurrency (async_runner , make_cases ,
705709 make_async_exec_ctx ):
706- ctx = make_async_exec_ctx (4 )
707- next (ctx )
708-
710+ make_async_exec_ctx (max_jobs = 4 )
709711 runner , _ = async_runner
710712 with pytest .raises (KeyboardInterrupt ):
711713 runner .runall (make_cases ([
@@ -723,9 +725,7 @@ def test_kbd_interrupt_in_wait_with_limited_concurrency(
723725 # KeyboardInterruptCheck to finish first (the corresponding wait should
724726 # trigger the failure), so as to make the framework kill the remaining
725727 # three.
726- ctx = make_async_exec_ctx (2 )
727- next (ctx )
728-
728+ make_async_exec_ctx (max_jobs = 2 )
729729 runner , _ = async_runner
730730 with pytest .raises (KeyboardInterrupt ):
731731 runner .runall (make_cases ([
@@ -738,9 +738,7 @@ def test_kbd_interrupt_in_wait_with_limited_concurrency(
738738
739739def test_kbd_interrupt_in_setup_with_concurrency (async_runner , make_cases ,
740740 make_async_exec_ctx ):
741- ctx = make_async_exec_ctx (4 )
742- next (ctx )
743-
741+ make_async_exec_ctx (max_jobs = 4 )
744742 runner , _ = async_runner
745743 with pytest .raises (KeyboardInterrupt ):
746744 runner .runall (make_cases ([
@@ -753,9 +751,7 @@ def test_kbd_interrupt_in_setup_with_concurrency(async_runner, make_cases,
753751
754752def test_kbd_interrupt_in_setup_with_limited_concurrency (
755753 async_runner , make_cases , make_async_exec_ctx ):
756- ctx = make_async_exec_ctx (2 )
757- next (ctx )
758-
754+ make_async_exec_ctx (max_jobs = 2 )
759755 runner , _ = async_runner
760756 with pytest .raises (KeyboardInterrupt ):
761757 runner .runall (make_cases ([
@@ -768,9 +764,7 @@ def test_kbd_interrupt_in_setup_with_limited_concurrency(
768764
769765def test_run_complete_fails_main_loop (async_runner , make_cases ,
770766 make_async_exec_ctx ):
771- ctx = make_async_exec_ctx (1 )
772- next (ctx )
773-
767+ make_async_exec_ctx (max_jobs = 1 )
774768 runner , _ = async_runner
775769 num_checks = 3
776770 runner .runall (make_cases ([SleepCheckPollFail (10 ),
@@ -788,9 +782,7 @@ def test_run_complete_fails_main_loop(async_runner, make_cases,
788782
789783def test_run_complete_fails_busy_loop (async_runner , make_cases ,
790784 make_async_exec_ctx ):
791- ctx = make_async_exec_ctx (1 )
792- next (ctx )
793-
785+ make_async_exec_ctx (max_jobs = 1 )
794786 runner , _ = async_runner
795787 num_checks = 3
796788 runner .runall (make_cases ([SleepCheckPollFailLate (1 ),
@@ -808,9 +800,7 @@ def test_run_complete_fails_busy_loop(async_runner, make_cases,
808800
809801def test_compile_fail_reschedule_main_loop (async_runner , make_cases ,
810802 make_async_exec_ctx ):
811- ctx = make_async_exec_ctx (1 )
812- next (ctx )
813-
803+ make_async_exec_ctx (max_jobs = 1 )
814804 runner , _ = async_runner
815805 num_checks = 2
816806 runner .runall (make_cases ([SleepCheckPollFail (.1 ), CompileFailureCheck ()]))
@@ -820,15 +810,10 @@ def test_compile_fail_reschedule_main_loop(async_runner, make_cases,
820810 assert_runall (runner )
821811 assert num_checks == len (stats .failed ())
822812
823- with contextlib .suppress (StopIteration ):
824- next (ctx )
825-
826813
827814def test_compile_fail_reschedule_busy_loop (async_runner , make_cases ,
828815 make_async_exec_ctx ):
829- ctx = make_async_exec_ctx (1 )
830- next (ctx )
831-
816+ make_async_exec_ctx (max_jobs = 1 )
832817 runner , _ = async_runner
833818 num_checks = 2
834819 runner .runall (
@@ -838,8 +823,6 @@ def test_compile_fail_reschedule_busy_loop(async_runner, make_cases,
838823 assert num_checks == stats .num_cases ()
839824 assert_runall (runner )
840825 assert num_checks == len (stats .failed ())
841- with contextlib .suppress (StopIteration ):
842- next (ctx )
843826
844827
845828@pytest .fixture
0 commit comments