Skip to content

Commit 1631142

Browse files
committed
nit
1 parent c22f6c7 commit 1631142

File tree

3 files changed

+35
-27
lines changed

3 files changed

+35
-27
lines changed

tests/e2e/test_complex_types.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ def table_fixture(self, connection_details):
1515
# Create the table
1616
cursor.execute(
1717
"""
18-
CREATE TABLE IF NOT EXISTS pysql_e2e_test_complex_types_table (
18+
CREATE TABLE IF NOT EXISTS pysql_test_complex_types_table (
1919
array_col ARRAY<STRING>,
2020
map_col MAP<STRING, INTEGER>,
2121
struct_col STRUCT<field1: STRING, field2: INTEGER>,
@@ -28,7 +28,7 @@ def table_fixture(self, connection_details):
2828
# Insert a record
2929
cursor.execute(
3030
"""
31-
INSERT INTO pysql_e2e_test_complex_types_table
31+
INSERT INTO pysql_test_complex_types_table
3232
VALUES (
3333
ARRAY('a', 'b', 'c'),
3434
MAP('a', 1, 'b', 2, 'c', 3),

tests/e2e/test_driver.py

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -856,7 +856,9 @@ def test_closing_a_closed_connection_doesnt_fail(self, caplog):
856856
raise KeyboardInterrupt("Simulated interrupt")
857857
finally:
858858
if conn is not None:
859-
assert not conn.open, "Connection should be closed after KeyboardInterrupt"
859+
assert (
860+
not conn.open
861+
), "Connection should be closed after KeyboardInterrupt"
860862

861863
def test_cursor_close_properly_closes_operation(self):
862864
"""Test that Cursor.close() properly closes the active operation handle on the server."""
@@ -883,7 +885,9 @@ def test_cursor_close_properly_closes_operation(self):
883885
raise KeyboardInterrupt("Simulated interrupt")
884886
finally:
885887
if cursor is not None:
886-
assert not cursor.open, "Cursor should be closed after KeyboardInterrupt"
888+
assert (
889+
not cursor.open
890+
), "Cursor should be closed after KeyboardInterrupt"
887891

888892
def test_nested_cursor_context_managers(self):
889893
"""Test that nested cursor context managers properly close operations on the server."""

tests/unit/test_client.py

Lines changed: 27 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -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

Comments
 (0)