@@ -490,22 +490,21 @@ def test_succeeds_on_api_worker(self, pulpcore_bindings, dispatch_task):
490490 assert task .worker is None
491491
492492 @pytest .mark .parallel
493- def test_executes_on_api_worker_when_no_async (self , pulpcore_bindings , dispatch_task , capsys ):
493+ def test_executes_on_api_worker_when_no_async (
494+ self , pulpcore_bindings , dispatch_task , monitor_task
495+ ):
494496 """
495497 GIVEN a task with no resource requirements
496498 AND the task IS NOT an async function
497499 WHEN dispatching a task as immediate
498- THEN the task completes with no associated worker
500+ THEN the dispatch should throw an error
499501 """
500- # TODO: on 3.85 this should throw an error
501- task_href = dispatch_task (
502- "pulpcore.app.tasks.test.sleep" , args = (LT_TIMEOUT ,), immediate = True
503- )
504- stderr_content = capsys .readouterr ().err
505- task = pulpcore_bindings .TasksApi .read (task_href )
506- assert task .state == "completed"
507- assert task .worker is None
508- assert "Support for non-coroutine immediate tasks will be dropped" in stderr_content
502+ with pytest .raises (PulpTaskError ) as ctx :
503+ task_href = dispatch_task (
504+ "pulpcore.app.tasks.test.sleep" , args = (LT_TIMEOUT ,), immediate = True
505+ )
506+ monitor_task (task_href )
507+ assert "Immediate tasks must be async functions" in ctx .value .task .error ["description" ]
509508
510509 @pytest .mark .parallel
511510 def test_timeouts_on_api_worker (self , pulpcore_bindings , dispatch_task ):
0 commit comments