Skip to content

Commit 061efb0

Browse files
committed
SQLAlchemy: Test suite adjustments for pandas software tests
1 parent 94de03e commit 061efb0

File tree

4 files changed

+20
-5
lines changed

4 files changed

+20
-5
lines changed

docs/conf.py

+1
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818

1919

2020
linkcheck_anchors = True
21+
linkcheck_ignore = [r"https://github.com/crate/cratedb-examples/blob/main/by-language/python-sqlalchemy/.*"]
2122

2223

2324
rst_prolog = """

setup.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ def read(path):
7070
'createcoverage>=1,<2',
7171
'stopit>=1.1.2,<2',
7272
'flake8>=4,<7',
73-
'pandas>=2,<3',
73+
'pandas',
7474
'pytz',
7575
# `test_http.py` needs `setuptools.ssl_support`
7676
'setuptools<57',

src/crate/client/sqlalchemy/tests/bulk_test.py

+4-2
Original file line numberDiff line numberDiff line change
@@ -19,13 +19,14 @@
1919
# with Crate these terms will supersede the license and you may use the
2020
# software solely pursuant to the terms of the relevant commercial agreement.
2121
import math
22+
import sys
2223
from unittest import TestCase, skipIf
2324
from unittest.mock import patch, MagicMock
2425

2526
import sqlalchemy as sa
2627
from sqlalchemy.orm import Session
2728

28-
from crate.client.sqlalchemy.sa_version import SA_VERSION, SA_2_0
29+
from crate.client.sqlalchemy.sa_version import SA_VERSION, SA_2_0, SA_1_4
2930

3031
try:
3132
from sqlalchemy.orm import declarative_base
@@ -168,12 +169,13 @@ def test_bulk_save_modern(self):
168169
)
169170
self.assertSequenceEqual(expected_bulk_args, bulk_args)
170171

172+
@skipIf(sys.version_info < (3, 8), "SQLAlchemy/pandas is not supported on Python <3.8")
173+
@skipIf(SA_VERSION < SA_1_4, "SQLAlchemy 1.3 is not supported by pandas")
171174
@patch('crate.client.connection.Cursor', mock_cursor=FakeCursor)
172175
def test_bulk_save_pandas(self, mock_cursor):
173176
"""
174177
Verify bulk INSERT with pandas.
175178
"""
176-
import sqlalchemy as sa
177179
from pandas._testing import makeTimeDataFrame
178180
from crate.client.sqlalchemy.support import insert_bulk
179181

src/crate/client/tests.py

+14-2
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@
2424
import json
2525
import os
2626
import socket
27+
import sys
2728
import unittest
2829
import doctest
2930
from pprint import pprint
@@ -40,6 +41,7 @@
4041
crate_host, crate_path, crate_port, \
4142
crate_transport_port, docs_path, localhost
4243
from crate.client import connect
44+
from .sqlalchemy import SA_VERSION, SA_1_4
4345

4446
from .test_cursor import CursorTest
4547
from .test_connection import ConnectionTest
@@ -382,13 +384,23 @@ def test_suite():
382384
s.layer = ensure_cratedb_layer()
383385
suite.addTest(s)
384386

385-
s = doctest.DocFileSuite(
387+
sqlalchemy_integration_tests = [
386388
'docs/by-example/sqlalchemy/getting-started.rst',
387389
'docs/by-example/sqlalchemy/crud.rst',
388390
'docs/by-example/sqlalchemy/working-with-types.rst',
389391
'docs/by-example/sqlalchemy/advanced-querying.rst',
390392
'docs/by-example/sqlalchemy/inspection-reflection.rst',
391-
'docs/by-example/sqlalchemy/dataframe.rst',
393+
]
394+
395+
# Don't run DataFrame integration tests on SQLAlchemy 1.3 and Python 3.7.
396+
skip_dataframe = SA_VERSION < SA_1_4 or sys.version_info < (3, 8)
397+
if not skip_dataframe:
398+
sqlalchemy_integration_tests += [
399+
'docs/by-example/sqlalchemy/dataframe.rst',
400+
]
401+
402+
s = doctest.DocFileSuite(
403+
*sqlalchemy_integration_tests,
392404
module_relative=False,
393405
setUp=setUpCrateLayerSqlAlchemy,
394406
tearDown=tearDownDropEntitiesSqlAlchemy,

0 commit comments

Comments
 (0)