@@ -758,7 +758,7 @@ def test_cursor_close_handles_exception(self):
758758 mock_backend = Mock ()
759759 mock_connection = Mock ()
760760 mock_op_handle = Mock ()
761-
761+
762762 mock_backend .close_command .side_effect = Exception ("Test error" )
763763
764764 cursor = client .Cursor (mock_connection , mock_backend )
@@ -767,78 +767,80 @@ def test_cursor_close_handles_exception(self):
767767 cursor .close ()
768768
769769 mock_backend .close_command .assert_called_once_with (mock_op_handle )
770-
770+
771771 self .assertIsNone (cursor .active_op_handle )
772-
772+
773773 self .assertFalse (cursor .open )
774774
775775 def test_cursor_context_manager_handles_exit_exception (self ):
776776 """Test that cursor's context manager handles exceptions during __exit__."""
777777 mock_backend = Mock ()
778778 mock_connection = Mock ()
779-
779+
780780 cursor = client .Cursor (mock_connection , mock_backend )
781781 original_close = cursor .close
782782 cursor .close = Mock (side_effect = Exception ("Test error during close" ))
783-
783+
784784 try :
785785 with cursor :
786786 raise ValueError ("Test error inside context" )
787787 except ValueError :
788788 pass
789-
789+
790790 cursor .close .assert_called_once ()
791791
792792 def test_connection_close_handles_cursor_close_exception (self ):
793793 """Test that _close handles exceptions from cursor.close() properly."""
794794 cursors_closed = []
795-
795+
796796 def mock_close_with_exception ():
797797 cursors_closed .append (1 )
798798 raise Exception ("Test error during close" )
799-
799+
800800 cursor1 = Mock ()
801801 cursor1 .close = mock_close_with_exception
802-
802+
803803 def mock_close_normal ():
804804 cursors_closed .append (2 )
805-
805+
806806 cursor2 = Mock ()
807807 cursor2 .close = mock_close_normal
808-
808+
809809 mock_backend = Mock ()
810810 mock_session_handle = Mock ()
811-
811+
812812 try :
813813 for cursor in [cursor1 , cursor2 ]:
814814 try :
815815 cursor .close ()
816816 except Exception :
817817 pass
818-
818+
819819 mock_backend .close_session (mock_session_handle )
820820 except Exception as e :
821821 self .fail (f"Connection close should handle exceptions: { e } " )
822-
823- self .assertEqual (cursors_closed , [1 , 2 ], "Both cursors should have close called" )
822+
823+ self .assertEqual (
824+ cursors_closed , [1 , 2 ], "Both cursors should have close called"
825+ )
824826
825827 def test_resultset_close_handles_cursor_already_closed_error (self ):
826828 """Test that ResultSet.close() handles CursorAlreadyClosedError properly."""
827829 result_set = client .ResultSet .__new__ (client .ResultSet )
828830 result_set .thrift_backend = Mock ()
829- result_set .thrift_backend .CLOSED_OP_STATE = ' CLOSED'
831+ result_set .thrift_backend .CLOSED_OP_STATE = " CLOSED"
830832 result_set .connection = Mock ()
831833 result_set .connection .open = True
832- result_set .op_state = ' RUNNING'
834+ result_set .op_state = " RUNNING"
833835 result_set .has_been_closed_server_side = False
834836 result_set .command_id = Mock ()
835837
836838 class MockRequestError (Exception ):
837839 def __init__ (self ):
838840 self .args = ["Error message" , CursorAlreadyClosedError ()]
839-
841+
840842 result_set .thrift_backend .close_command .side_effect = MockRequestError ()
841-
843+
842844 original_close = client .ResultSet .close
843845 try :
844846 try :
@@ -854,11 +856,13 @@ def __init__(self):
854856 finally :
855857 result_set .has_been_closed_server_side = True
856858 result_set .op_state = result_set .thrift_backend .CLOSED_OP_STATE
857-
858- result_set .thrift_backend .close_command .assert_called_once_with (result_set .command_id )
859-
859+
860+ result_set .thrift_backend .close_command .assert_called_once_with (
861+ result_set .command_id
862+ )
863+
860864 assert result_set .has_been_closed_server_side is True
861-
865+
862866 assert result_set .op_state == result_set .thrift_backend .CLOSED_OP_STATE
863867 finally :
864868 pass
0 commit comments