Skip to content

Commit 66cc90b

Browse files
authored
SNOW-1882588 Add Test for PR 2136 (#2138)
1 parent fc5f548 commit 66cc90b

File tree

1 file changed

+15
-0
lines changed

1 file changed

+15
-0
lines changed

test/unit/test_cursor.py

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,21 @@ def test_cursor_attribute():
6262
assert cursor.lastrowid is None
6363

6464

65+
def test_query_can_be_empty_with_dataframe_ast():
66+
def mock_is_closed(*args, **kwargs):
67+
return False
68+
69+
fake_conn = FakeConnection()
70+
fake_conn.is_closed = mock_is_closed
71+
cursor = SnowflakeCursor(fake_conn)
72+
# when `dataframe_ast` is not presented, the execute function return None
73+
assert cursor.execute("") is None
74+
# when `dataframe_ast` is presented, it should not return `None`
75+
# but raise `AttributeError` since `_paramstyle` is not set in FakeConnection.
76+
with pytest.raises(AttributeError):
77+
cursor.execute("", _dataframe_ast="ABCD")
78+
79+
6580
@patch("snowflake.connector.cursor.SnowflakeCursor._SnowflakeCursor__cancel_query")
6681
def test_cursor_execute_timeout(mockCancelQuery):
6782
def mock_cmd_query(*args, **kwargs):

0 commit comments

Comments
 (0)