Skip to content

Commit ff096d0

Browse files
committed
test(cursor, test_insert_data_column_stmt): Adjust for py36
1 parent 0c9fe23 commit ff096d0

File tree

1 file changed

+4
-7
lines changed

1 file changed

+4
-7
lines changed

test/unit/test_cursor.py

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import typing
2+
from io import StringIO
23
from test.utils import pandas_only
34
from unittest.mock import Mock, PropertyMock, mock_open, patch
45

@@ -272,12 +273,6 @@ def test_insert_data_column_names_indexes_mismatch_raises(indexes, names, mocker
272273
)
273274

274275

275-
in_mem_csv = """\
276-
col1,col2,col3
277-
1,3,foo
278-
2,5,bar
279-
-1,7,baz"""
280-
281276
insert_bulk_data = [
282277
(
283278
[0],
@@ -332,7 +327,7 @@ def test_insert_data_column_names_indexes_mismatch_raises(indexes, names, mocker
332327
]
333328

334329

335-
@patch("builtins.open", new_callable=mock_open, read_data=in_mem_csv)
330+
@patch("builtins.open", new_callable=mock_open)
336331
@pytest.mark.parametrize("indexes,names,exp_execute_args", insert_bulk_data)
337332
def test_insert_data_column_stmt(mocked_csv, indexes, names, exp_execute_args, mocker):
338333
# mock fetchone to return "True" to ensure the table_name and column_name
@@ -347,6 +342,8 @@ def test_insert_data_column_stmt(mocked_csv, indexes, names, exp_execute_args, m
347342
mock_cursor._c = Mock()
348343
mock_cursor.paramstyle = "qmark"
349344

345+
mocked_csv.side_effect = [StringIO("""\col1,col2,col3\n1,3,foo\n2,5,bar\n-1,7,baz""")]
346+
350347
mock_cursor.insert_data_bulk(
351348
filename="mocked_csv",
352349
table_name="test_table",

0 commit comments

Comments
 (0)