File tree Expand file tree Collapse file tree 2 files changed +2
-26
lines changed Expand file tree Collapse file tree 2 files changed +2
-26
lines changed Original file line number Diff line number Diff line change 1616from mssql_python .constants import ConstantsDDBC as ddbc_sql_const
1717from mssql_python .helpers import check_error , log
1818from mssql_python import ddbc_bindings
19- from mssql_python .exceptions import InterfaceError
19+ from mssql_python .exceptions import InterfaceError , ProgrammingError
2020from .row import Row
2121
2222
@@ -438,7 +438,7 @@ def close(self) -> None:
438438 Close the cursor now (rather than whenever __del__ is called).
439439 """
440440 if self .closed :
441- return
441+ raise ProgrammingError ( "Cursor is already closed." )
442442
443443 if self .hstmt :
444444 self .hstmt .free ()
Original file line number Diff line number Diff line change @@ -1599,30 +1599,6 @@ def test_cursor_context_manager_enter_returns_self(db_connection):
15991599 # Cursor should be closed after context exit
16001600 assert cursor .closed
16011601
1602- def test_double_close (db_connection ):
1603- """Test that calling cursor.close() multiple times is idempotent and doesn't raise an exception"""
1604- try :
1605- cursor = db_connection .cursor ()
1606-
1607- # First close() call
1608- cursor .close ()
1609- assert cursor .closed , "Cursor should be closed after first close() call"
1610-
1611- # Second close() call - should be a no-op and not raise an exception
1612- cursor .close ()
1613- assert cursor .closed , "Cursor should still be closed after second close() call"
1614-
1615- # Multiple additional close() calls - should also be no-ops
1616- cursor .close ()
1617- cursor .close ()
1618- assert cursor .closed , "Cursor should remain closed after multiple close() calls"
1619-
1620- except Exception as e :
1621- pytest .fail (f"Multiple cursor.close() calls test failed: { e } " )
1622- finally :
1623- # Create a new cursor for any subsequent tests
1624- cursor = db_connection .cursor ()
1625-
16261602def test_close (db_connection ):
16271603 """Test closing the cursor"""
16281604 try :
You can’t perform that action at this time.
0 commit comments