@@ -33,7 +33,7 @@ async def test_benchmark_from_existing(self, async_sdk_client: AsyncRunloopSDK)
3333 benchmarks = benchmarks_page .benchmarks
3434
3535 if not benchmarks :
36- pytest . skip ("No benchmarks available to test" )
36+ raise Exception ("No benchmarks available to test" )
3737
3838 benchmark_data = benchmarks [0 ]
3939
@@ -69,9 +69,11 @@ async def test_benchmark_run_and_cancel(self, async_sdk_client: AsyncRunloopSDK)
6969 benchmarks = benchmarks_page .benchmarks
7070
7171 if not benchmarks :
72- pytest . skip ("No benchmarks available to test" )
72+ raise Exception ("No benchmarks available to test" )
7373
7474 benchmark_data = benchmarks [0 ]
75+ if not benchmark_data .scenario_ids :
76+ raise Exception ("No scenarios available to test" )
7577
7678 # Create AsyncBenchmark wrapper
7779 benchmark = AsyncBenchmark (
@@ -81,14 +83,8 @@ async def test_benchmark_run_and_cancel(self, async_sdk_client: AsyncRunloopSDK)
8183
8284 # Start a run
8385 run = await benchmark .run (run_name = "sdk-smoketest-async-benchmark-run" )
84-
85- # If the benchmark has scenarios, run one
86- scenario_runs : list [AsyncScenarioRun ] = []
87- if benchmark_data .scenario_ids :
88- scenario = async_sdk_client .scenario .from_id (benchmark_data .scenario_ids [0 ])
89- scenario_runs .append (
90- await scenario .run (benchmark_run_id = run .id , run_name = "sdk-smoketest-async-benchmark-run-scenario" )
91- )
86+ scenario = async_sdk_client .scenario .from_id (benchmark_data .scenario_ids [0 ])
87+ scenario_run = None
9288
9389 try :
9490 assert isinstance (run , AsyncBenchmarkRun )
@@ -100,30 +96,30 @@ async def test_benchmark_run_and_cancel(self, async_sdk_client: AsyncRunloopSDK)
10096 assert info .id == run .id
10197 assert info .state in ["running" , "completed" , "canceled" ]
10298
103- bench_scenario_runs = await run .list_scenario_runs ()
104- assert isinstance (bench_scenario_runs , list )
105- assert len (bench_scenario_runs ) == len (scenario_runs )
106- for bench_scenario_run in bench_scenario_runs :
107- assert isinstance (bench_scenario_run , AsyncScenarioRun )
108- assert bench_scenario_run .id == scenario_runs [0 ].id
109- assert bench_scenario_run .devbox_id == scenario_runs [0 ].devbox_id
99+ # Start a scenario run
100+ scenario_run = await scenario .run (
101+ benchmark_run_id = run .id , run_name = "sdk-smoketest-async-benchmark-run-scenario"
102+ )
103+ scenario_runs = await run .list_scenario_runs ()
104+ assert isinstance (scenario_runs , list )
105+ assert len (scenario_runs ) == 1
106+ assert isinstance (scenario_runs [0 ], AsyncScenarioRun )
107+ assert scenario_runs [0 ].id == scenario_run .id
108+ assert scenario_runs [0 ].devbox_id == scenario_run .devbox_id
110109
111- # Cancel the scenario run
112- scenario_result = await bench_scenario_run .cancel ()
113- assert scenario_result .state in ["canceled" , "completed" ]
110+ # Cancel the scenario run
111+ scenario_result = await scenario_run .cancel ()
112+ assert scenario_result .state in ["canceled" , "completed" ]
114113
115114 # Cancel the benchmark run
116115 result = await run .cancel ()
117116 assert result .state in ["canceled" , "completed" ]
118117
119118 except Exception :
120119 # Ensure cleanup on any error
121- try :
122- for scenario_run in scenario_runs :
123- await async_sdk_client .api .scenarios .runs .cancel (scenario_run .id )
124- await async_sdk_client .api .benchmarks .runs .cancel (run .id )
125- except Exception :
126- pass
120+ if scenario_run :
121+ await async_sdk_client .api .scenarios .runs .cancel (scenario_run .id )
122+ await async_sdk_client .api .benchmarks .runs .cancel (run .id )
127123 raise
128124
129125
@@ -144,7 +140,7 @@ async def test_list_runs(self, async_sdk_client: AsyncRunloopSDK) -> None:
144140 benchmarks = benchmarks_page .benchmarks
145141
146142 if not benchmarks :
147- pytest . skip ("No benchmarks available to test" )
143+ raise Exception ("No benchmarks available to test" )
148144
149145 benchmark_data = benchmarks [0 ]
150146
0 commit comments