diff --git a/tests/guardrails_tests/test_eu_ai_act_article5.py b/tests/guardrails_tests/test_eu_ai_act_article5.py index 62fdb002995..172617e4b20 100644 --- a/tests/guardrails_tests/test_eu_ai_act_article5.py +++ b/tests/guardrails_tests/test_eu_ai_act_article5.py @@ -307,12 +307,13 @@ class TestEUAIActPerformance: monkeypatch.setattr(httpx.AsyncClient, "send", _no_network) monkeypatch.setattr(httpx.Client, "send", _no_network) - with pytest.raises(HTTPException, match="Content blocked: eu_ai_act_article"): + with pytest.raises(HTTPException, match="Content blocked: eu_ai_act_article") as exc_info: await content_filter_guardrail.apply_guardrail( inputs={"texts": [sentence]}, request_data=request_data, input_type="request", ) + assert exc_info.value.status_code == 400 if __name__ == "__main__": diff --git a/tests/guardrails_tests/test_sg_mas_ai_guardrails.py b/tests/guardrails_tests/test_sg_mas_ai_guardrails.py index 9889ff511c1..fa76b2928fd 100644 --- a/tests/guardrails_tests/test_sg_mas_ai_guardrails.py +++ b/tests/guardrails_tests/test_sg_mas_ai_guardrails.py @@ -540,12 +540,13 @@ class TestMASEdgeCases: monkeypatch.setattr(httpx.AsyncClient, "send", _no_network) monkeypatch.setattr(httpx.Client, "send", _no_network) - with pytest.raises(HTTPException, match="Content blocked: sg_mas_human_oversight"): + with pytest.raises(HTTPException, match="Content blocked: sg_mas_human_oversight") as exc_info: await oversight_guardrail.apply_guardrail( inputs={"texts": [sentence]}, request_data=request_data, input_type="request", ) + assert exc_info.value.status_code == 400 class TestMASPerformance: diff --git a/tests/guardrails_tests/test_sg_pdpa_guardrails.py b/tests/guardrails_tests/test_sg_pdpa_guardrails.py index 711b2657d8e..89ec3a6a506 100644 --- a/tests/guardrails_tests/test_sg_pdpa_guardrails.py +++ b/tests/guardrails_tests/test_sg_pdpa_guardrails.py @@ -576,12 +576,13 @@ class TestSGPDPAEdgeCases: monkeypatch.setattr(httpx.AsyncClient, "send", _no_network) monkeypatch.setattr(httpx.Client, "send", _no_network) - with pytest.raises(HTTPException, match="Content blocked: sg_pdpa_personal_identifiers"): + with pytest.raises(HTTPException, match="Content blocked: sg_pdpa_personal_identifiers") as exc_info: await personal_identifiers_guardrail.apply_guardrail( inputs={"texts": [sentence]}, request_data=request_data, input_type="request", ) + assert exc_info.value.status_code == 400 @pytest.mark.asyncio async def test_multiple_violations(self, personal_identifiers_guardrail):