@@ -219,7 +219,7 @@ def test_cannot_access_endpoints(
219219 "get_oidc_config"
220220 ) # get_oidc_config can be accessed without auth
221221 for get_method in blueapi_rest_client_get_methods :
222- with pytest .raises (UnauthorisedAccessError , match = r"<Response \[401\]> " ):
222+ with pytest .raises (UnauthorisedAccessError , match = r"Not authenticated " ):
223223 getattr (client_without_auth ._rest , get_method )()
224224
225225
@@ -245,7 +245,7 @@ def test_get_plans_by_name(client: BlueapiClient, expected_plans: PlanResponse):
245245
246246
247247def test_get_non_existent_plan (rest_client : BlueapiRestClient ):
248- with pytest .raises (NotFoundError ):
248+ with pytest .raises (NotFoundError , match = r"Item not found" ):
249249 rest_client .get_plan ("Not exists" )
250250
251251
@@ -270,12 +270,12 @@ def test_get_device_by_name(
270270
271271
272272def test_get_non_existent_device (rest_client : BlueapiRestClient ):
273- with pytest .raises (NotFoundError ):
273+ with pytest .raises (NotFoundError , match = r"Item not found" ):
274274 rest_client .get_device ("Not exists" )
275275
276276
277277def test_client_non_existent_device (client : BlueapiClient ):
278- with pytest .raises (AttributeError ):
278+ with pytest .raises (AttributeError , match = "No device named 'missing' available" ):
279279 _ = client .devices .missing
280280
281281
@@ -297,7 +297,7 @@ def test_instrument_session_propagated(rest_client: BlueapiRestClient):
297297
298298
299299def test_create_task_validation_error (rest_client : BlueapiRestClient ):
300- with pytest .raises (BlueskyRequestError ):
300+ with pytest .raises (BlueskyRequestError , match = "Internal Server Error" ):
301301 rest_client .create_task (
302302 TaskRequest (
303303 name = "Not-exists" ,
@@ -338,12 +338,12 @@ def test_get_task_by_id(rest_client: BlueapiRestClient):
338338
339339
340340def test_get_non_existent_task (rest_client : BlueapiRestClient ):
341- with pytest .raises (NotFoundError ):
341+ with pytest .raises (NotFoundError , match = r"Item not found" ):
342342 rest_client .get_task ("Not-exists" )
343343
344344
345345def test_delete_non_existent_task (rest_client : BlueapiRestClient ):
346- with pytest .raises (NotFoundError ):
346+ with pytest .raises (NotFoundError , match = r"Item not found" ):
347347 rest_client .clear_task ("Not-exists" )
348348
349349
@@ -365,7 +365,7 @@ def test_put_worker_task_fails_if_not_idle(rest_client: BlueapiRestClient):
365365
366366 with pytest .raises (BlueskyRemoteControlError ) as exception :
367367 rest_client .update_worker_task (WorkerTask (task_id = small_task .task_id ))
368- assert "<Response [409]> " in str ( exception )
368+ assert "Worker already active " in exception . value . args [ 0 ]
369369 rest_client .cancel_current_task (WorkerState .ABORTING )
370370 rest_client .clear_task (small_task .task_id )
371371 rest_client .clear_task (long_task .task_id )
@@ -378,10 +378,10 @@ def test_get_worker_state(client: BlueapiClient):
378378def test_set_state_transition_error (client : BlueapiClient ):
379379 with pytest .raises (BlueskyRemoteControlError ) as exception :
380380 client .resume ()
381- assert "<Response [400]>" in str ( exception )
381+ assert exception . value . args [ 0 ]
382382 with pytest .raises (BlueskyRemoteControlError ) as exception :
383383 client .pause ()
384- assert "<Response [400]>" in str ( exception )
384+ assert exception . value . args [ 0 ]
385385
386386
387387def test_get_task_by_status (rest_client : BlueapiRestClient ):
0 commit comments