From fa80c28f81ada76054156bc372972680567b77ba Mon Sep 17 00:00:00 2001 From: Ishaan Jaffer Date: Tue, 17 Feb 2026 16:02:12 -0800 Subject: [PATCH] Make conditional match assertion more robust - Use getattr to safely access exception detail field - Check if detail is dict before calling .get() - Addresses Greptile feedback about brittle string assertion --- tests/guardrails_tests/test_eu_ai_act_french_3_scenarios.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/tests/guardrails_tests/test_eu_ai_act_french_3_scenarios.py b/tests/guardrails_tests/test_eu_ai_act_french_3_scenarios.py index e6fe01da7f3..d159c74aea8 100644 --- a/tests/guardrails_tests/test_eu_ai_act_french_3_scenarios.py +++ b/tests/guardrails_tests/test_eu_ai_act_french_3_scenarios.py @@ -189,9 +189,10 @@ class TestEUAIActFrench3Scenarios: ) # Verify it's a conditional match, not an always_block match - error_msg = str(exc_info.value) + error_detail = getattr(exc_info.value, 'detail', {}) + error_msg = error_detail.get("error", str(exc_info.value)) if isinstance(error_detail, dict) else str(exc_info.value) assert "conditional match" in error_msg.lower(), \ - f"Expected conditional match but got: {error_msg}" + f"Expected conditional match but got: {error_detail}" print(f"✓ PURE CONDITIONAL MATCHING PASSED") print(f" Reason: {exc_info.value}\n")