Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def test_executemanycolumns_without_numpy_support(dsn, configuration):
with open_cursor(configuration) as cursor:
with patch('turbodbc.cursor._has_numpy_support', return_value=False):
with pytest.raises(turbodbc.Error):
cursor.executemanycolumns("SELECT 42", [])
def test_no_arrow_support(dsn, configuration):
with open_cursor(configuration) as cursor:
cursor.execute("SELECT 42")
with patch('turbodbc.cursor._has_arrow_support', return_value=False):
with pytest.raises(turbodbc.Error):
cursor.fetchallarrow()
def test_select_with_too_many_parameters_raises(dsn, configuration):
with open_cursor(configuration) as cursor:
with pytest.raises(turbodbc.Error):
cursor.execute("SELECT 42", [42])
with pytest.raises(turbodbc.Error):
cursor.executemany("SELECT 42", [[42]])
def test_select_with_too_many_parameters_raises(dsn, configuration):
with open_cursor(configuration) as cursor:
with pytest.raises(turbodbc.Error):
cursor.execute("SELECT 42", [42])
with pytest.raises(turbodbc.Error):
cursor.executemany("SELECT 42", [[42]])
def test_rowcount_is_reset_after_executemanycolumns_raises(dsn, configuration):
with open_cursor(configuration) as cursor:
with query_fixture(cursor, configuration, 'INSERT INTEGER') as table_name:
cursor.execute("INSERT INTO {} VALUES (?)".format(table_name), [42])
assert cursor.rowcount == 1
with pytest.raises(Error):
cursor.executemanycolumns("this is not even a valid SQL statement", [])
assert cursor.rowcount == -1
def test_no_numpy_support(dsn, configuration):
with open_cursor(configuration) as cursor:
cursor.execute("SELECT 42")
with patch('turbodbc.cursor._has_numpy_support', return_value=False):
with pytest.raises(turbodbc.Error):
cursor.fetchallnumpy()
def test_rowcount_is_reset_after_execute_raises(dsn, configuration):
with open_cursor(configuration) as cursor:
with query_fixture(cursor, configuration, 'INSERT INTEGER') as table_name:
cursor.execute("INSERT INTO {} VALUES (?)".format(table_name), [42])
assert cursor.rowcount == 1
with pytest.raises(Error):
cursor.execute("this is not even a valid SQL statement")
assert cursor.rowcount == -1