From 19db02c0ec8a884a6eb0209abda6306cc26f0ae7 Mon Sep 17 00:00:00 2001 From: Dmitry Kropachev Date: Fri, 31 Jul 2026 14:31:10 -0400 Subject: [PATCH] tests: avoid assertNoLogs on Python 3.9 --- tests/unit/test_response_future.py | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/tests/unit/test_response_future.py b/tests/unit/test_response_future.py index cf1194a91f..232ecf6585 100644 --- a/tests/unit/test_response_future.py +++ b/tests/unit/test_response_future.py @@ -16,7 +16,7 @@ from collections import deque from threading import RLock -from unittest.mock import Mock, MagicMock, ANY +from unittest.mock import Mock, MagicMock, ANY, patch from cassandra import ConsistencyLevel, Unavailable, SchemaTargetType, SchemaChangeType, OperationTimedOut from cassandra.cluster import Session, ResponseFuture, NoHostAvailable, ProtocolVersion, ControlConnectionQueryFallback @@ -1316,8 +1316,9 @@ def test_set_result_no_metadata_statement_adopts_metadata_changed(self): ) # Ordinary METADATA_CHANGED handling, so no anomaly warning either. - with self.assertNoLogs('cassandra.cluster', level='WARNING'): + with patch('cassandra.cluster.log.warning') as warning: rf._set_result(None, None, None, response) + warning.assert_not_called() assert ps.result_metadata_and_id == (new_meta, b'new_id') @@ -1351,8 +1352,9 @@ def test_set_result_anomalous_metadata_id_warns_once_and_rearms(self): assert sum('result_metadata_id' in msg for msg in first.output) == 1 # Second identical anomalous response: no new warning (deduped). - with self.assertNoLogs('cassandra.cluster', level='WARNING'): + with patch('cassandra.cluster.log.warning') as warning: rf._set_result(None, None, None, anomalous) + warning.assert_not_called() assert ps.result_metadata_and_id == (old_meta, b'old_id') # A genuine METADATA_CHANGED recovers the metadata and re-arms the warning.