From 136db260ca028dfd3e32e484d83528629e6309a1 Mon Sep 17 00:00:00 2001 From: Andrzej Jackowski Date: Mon, 2 Feb 2026 10:20:06 +0100 Subject: [PATCH] test: specify exceptions being caught in guardrails_test.py Before this commit, the test caught a broad `Exception`. This change specifies the expected exceptions to avoid a situation where the product or test is broken and it goes undetected. --- test/cluster/dtest/guardrails_test.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/test/cluster/dtest/guardrails_test.py b/test/cluster/dtest/guardrails_test.py index 4ecc8e072f..724a7a5e37 100644 --- a/test/cluster/dtest/guardrails_test.py +++ b/test/cluster/dtest/guardrails_test.py @@ -8,6 +8,7 @@ import logging import pytest from cassandra.cluster import Session +from cassandra.protocol import ConfigurationException, InvalidRequest from dtest_class import Tester @@ -27,9 +28,9 @@ def create_ks_and_assert_warning(session, query, ks_name, key_warn_msg_words): def assert_creating_ks_fails(session, query, ks_name): - with pytest.raises(Exception): + with pytest.raises(ConfigurationException): session.execute(query) - with pytest.raises(Exception): + with pytest.raises(InvalidRequest): session.execute(f"USE {ks_name}")