From e2c0e53fb0a064949992ad29803e1957b3b27b1f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Dawid=20M=C4=99drek?= Date: Mon, 3 Aug 2026 23:00:46 +0200 Subject: [PATCH 1/2] Fix regular expression strings The strings didn't use the characters they intended because the backslashes effectively resulted in special characters. We fix them by marking the strings as raw. --- tests/integration/__init__.py | 6 +++--- tests/unit/test_exception.py | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/tests/integration/__init__.py b/tests/integration/__init__.py index a91617f494..6118d961da 100644 --- a/tests/integration/__init__.py +++ b/tests/integration/__init__.py @@ -976,9 +976,9 @@ def __new__(cls, **kwargs): # introduced by CASSANDRA-15234 class Cassandra41CCMCluster(CCMCluster): __test__ = False - IN_MS_REGEX = re.compile('^(\w+)_in_ms$') - IN_KB_REGEX = re.compile('^(\w+)_in_kb$') - ENABLE_REGEX = re.compile('^enable_(\w+)$') + IN_MS_REGEX = re.compile(r'^(\w+)_in_ms$') + IN_KB_REGEX = re.compile(r'^(\w+)_in_kb$') + ENABLE_REGEX = re.compile(r'^enable_(\w+)$') def _get_config_key(self, k, v): if "." in k: diff --git a/tests/unit/test_exception.py b/tests/unit/test_exception.py index 6bddd96a4b..0ac4052a63 100644 --- a/tests/unit/test_exception.py +++ b/tests/unit/test_exception.py @@ -29,7 +29,7 @@ def extract_consistency(self, msg): :param msg: message with consistency value :return: String representing consistency value """ - match = re.search("'consistency':\s+'([\w\s]+)'", msg) + match = re.search(r"'consistency':\s+'([\w\s]+)'", msg) return match and match.group(1) def test_timeout_consistency(self): From 37d56e9c704b8e06e07e37d1d641f6ed843e6f32 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Dawid=20M=C4=99drek?= Date: Mon, 3 Aug 2026 23:02:54 +0200 Subject: [PATCH 2/2] Avoid using is not with a literal The operator `is not` comapres the memory addresses of two objects. Since we're comparing an expression against a literal, it made no sense and was reported by Python. Fix it by moving on to using the operator `!=`. --- tests/unit/io/utils.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/unit/io/utils.py b/tests/unit/io/utils.py index f43224058c..b821ee1897 100644 --- a/tests/unit/io/utils.py +++ b/tests/unit/io/utils.py @@ -120,7 +120,7 @@ def submit_and_wait_for_completion(unit_test, create_timer, start, end, incremen pending_callbacks.append(callback) # wait for all the callbacks associated with the timers to be invoked - while len(pending_callbacks) is not 0: + while len(pending_callbacks) != 0: for callback in pending_callbacks: if callback.was_invoked(): pending_callbacks.remove(callback)