@@ -352,7 +352,7 @@ def test_context_manager_closes_cursor(self):
352352 cursor .close .assert_called ()
353353
354354 @patch ("%s.client.ThriftBackend" % PACKAGE_NAME )
355- def test_context_manager_closes_connection (self , mock_client_class ):
355+ def test_a_context_manager_closes_connection (self , mock_client_class ):
356356 print ("hellow1" )
357357 instance = mock_client_class .return_value
358358
@@ -790,41 +790,41 @@ def test_cursor_context_manager_handles_exit_exception(self):
790790
791791 cursor .close .assert_called_once ()
792792
793- # def test_connection_close_handles_cursor_close_exception(self):
794- # """Test that _close handles exceptions from cursor.close() properly."""
795- # print("banana")
796- # cursors_closed = []
793+ def test_connection_close_handles_cursor_close_exception (self ):
794+ """Test that _close handles exceptions from cursor.close() properly."""
795+ print ("banana" )
796+ cursors_closed = []
797797
798- # def mock_close_with_exception():
799- # cursors_closed.append(1)
800- # raise Exception("Test error during close")
798+ def mock_close_with_exception ():
799+ cursors_closed .append (1 )
800+ raise Exception ("Test error during close" )
801801
802- # cursor1 = Mock()
803- # cursor1.close = mock_close_with_exception
802+ cursor1 = Mock ()
803+ cursor1 .close = mock_close_with_exception
804804
805- # def mock_close_normal():
806- # cursors_closed.append(2)
805+ def mock_close_normal ():
806+ cursors_closed .append (2 )
807807
808- # cursor2 = Mock()
809- # cursor2.close = mock_close_normal
808+ cursor2 = Mock ()
809+ cursor2 .close = mock_close_normal
810810
811- # mock_backend = Mock()
812- # mock_session_handle = Mock()
811+ mock_backend = Mock ()
812+ mock_session_handle = Mock ()
813813
814- # try:
815- # for cursor in [cursor1, cursor2]:
816- # try:
817- # cursor.close()
818- # except Exception:
819- # pass
814+ try :
815+ for cursor in [cursor1 , cursor2 ]:
816+ try :
817+ cursor .close ()
818+ except Exception :
819+ pass
820820
821- # mock_backend.close_session(mock_session_handle)
822- # except Exception as e:
823- # self.fail(f"Connection close should handle exceptions: {e}")
821+ mock_backend .close_session (mock_session_handle )
822+ except Exception as e :
823+ self .fail (f"Connection close should handle exceptions: { e } " )
824824
825- # self.assertEqual(
826- # cursors_closed, [1, 2], "Both cursors should have close called"
827- # )
825+ self .assertEqual (
826+ cursors_closed , [1 , 2 ], "Both cursors should have close called"
827+ )
828828
829829 def test_resultset_close_handles_cursor_already_closed_error (self ):
830830 """Test that ResultSet.close() handles CursorAlreadyClosedError properly."""
0 commit comments