@@ -39,6 +39,11 @@ def new(cls):
3939 cls .apply_property_to_mock (ThriftBackendMock , staging_allowed_local_path = None )
4040 MockTExecuteStatementResp = MagicMock (spec = TExecuteStatementResp ())
4141
42+ # Mock retry_policy with history attribute
43+ mock_retry_policy = Mock ()
44+ mock_retry_policy .history = []
45+ cls .apply_property_to_mock (ThriftBackendMock , retry_policy = mock_retry_policy )
46+
4247 cls .apply_property_to_mock (
4348 MockTExecuteStatementResp ,
4449 description = None ,
@@ -70,6 +75,15 @@ def apply_property_to_mock(self, mock_obj, **kwargs):
7075 prop = PropertyMock (** kwargs )
7176 setattr (type (mock_obj ), key , prop )
7277
78+ @classmethod
79+ def mock_thrift_backend_with_retry_policy (cls ): # Required for log_latency() decorator
80+ """Create a simple thrift_backend mock with retry_policy for basic tests."""
81+ mock_thrift_backend = Mock ()
82+ mock_retry_policy = Mock ()
83+ mock_retry_policy .history = []
84+ mock_thrift_backend .retry_policy = mock_retry_policy
85+ return mock_thrift_backend
86+
7387
7488class ClientTestSuite (unittest .TestCase ):
7589 """
@@ -319,7 +333,7 @@ def test_executing_multiple_commands_uses_the_most_recent_command(
319333 mock_result_sets [1 ].fetchall .assert_called_once_with ()
320334
321335 def test_closed_cursor_doesnt_allow_operations (self ):
322- cursor = client .Cursor (Mock (), Mock ())
336+ cursor = client .Cursor (Mock (), ThriftBackendMockFactory . mock_thrift_backend_with_retry_policy ())
323337 cursor .close ()
324338
325339 with self .assertRaises (Error ) as e :
@@ -399,7 +413,7 @@ def test_get_schemas_parameters_passed_to_thrift_backend(self, mock_thrift_backe
399413 for req_args in req_args_combinations :
400414 req_args = {k : v for k , v in req_args .items () if v != "NOT_SET" }
401415 with self .subTest (req_args = req_args ):
402- mock_thrift_backend = Mock ()
416+ mock_thrift_backend = ThriftBackendMockFactory . mock_thrift_backend_with_retry_policy ()
403417
404418 cursor = client .Cursor (Mock (), mock_thrift_backend )
405419 cursor .schemas (** req_args )
@@ -422,7 +436,7 @@ def test_get_tables_parameters_passed_to_thrift_backend(self, mock_thrift_backen
422436 for req_args in req_args_combinations :
423437 req_args = {k : v for k , v in req_args .items () if v != "NOT_SET" }
424438 with self .subTest (req_args = req_args ):
425- mock_thrift_backend = Mock ()
439+ mock_thrift_backend = ThriftBackendMockFactory . mock_thrift_backend_with_retry_policy ()
426440
427441 cursor = client .Cursor (Mock (), mock_thrift_backend )
428442 cursor .tables (** req_args )
@@ -445,7 +459,7 @@ def test_get_columns_parameters_passed_to_thrift_backend(self, mock_thrift_backe
445459 for req_args in req_args_combinations :
446460 req_args = {k : v for k , v in req_args .items () if v != "NOT_SET" }
447461 with self .subTest (req_args = req_args ):
448- mock_thrift_backend = Mock ()
462+ mock_thrift_backend = ThriftBackendMockFactory . mock_thrift_backend_with_retry_policy ()
449463
450464 cursor = client .Cursor (Mock (), mock_thrift_backend )
451465 cursor .columns (** req_args )
0 commit comments