Skip to content

Commit d2c7613

Browse files
committed
Chore: Fix tests on SQLAlchemy 1.3, by skipping them
We don't know which circumstances cause this problem. SQLAlchemy 1.3 is EOL anyway, so we don't care too much. sqlalchemy.exc.InvalidRequestError: When initializing mapper mapped class RootStore->root, expression 'ItemStore' failed to locate a name ('ItemStore').
1 parent 97e4b64 commit d2c7613

File tree

5 files changed

+19
-11
lines changed

5 files changed

+19
-11
lines changed

tests/compiler_test.py

+1-3
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,6 @@
1818
# However, if you have executed another commercial license agreement
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.
21-
import sys
2221
import warnings
2322
from textwrap import dedent
2423
from unittest import mock, skipIf, TestCase
@@ -289,8 +288,7 @@ def test_for_update(self):
289288
FakeCursor = MagicMock(name='FakeCursor', spec=Cursor)
290289

291290

292-
@skipIf(SA_VERSION < SA_1_4 and (3, 9) <= sys.version_info < (3, 10),
293-
"SQLAlchemy 1.3 has problems with these test cases on Python 3.9")
291+
@skipIf(SA_VERSION < SA_1_4, "SQLAlchemy 1.3 suddenly has problems with these test cases")
294292
class CompilerTestCase(TestCase):
295293
"""
296294
A base class for providing mocking infrastructure to validate the DDL compiler.

tests/datetime_test.py

+6-1
Original file line numberDiff line numberDiff line change
@@ -20,13 +20,17 @@
2020
# software solely pursuant to the terms of the relevant commercial agreement.
2121

2222
from __future__ import absolute_import
23+
2324
from datetime import datetime, tzinfo, timedelta
24-
from unittest import TestCase
25+
from unittest import TestCase, skipIf
2526
from unittest.mock import patch, MagicMock
2627

2728
import sqlalchemy as sa
2829
from sqlalchemy.exc import DBAPIError
2930
from sqlalchemy.orm import Session
31+
32+
from sqlalchemy_cratedb import SA_VERSION, SA_1_4
33+
3034
try:
3135
from sqlalchemy.orm import declarative_base
3236
except ImportError:
@@ -52,6 +56,7 @@ def dst(self, date_time):
5256
return timedelta(seconds=-7200)
5357

5458

59+
@skipIf(SA_VERSION < SA_1_4, "SQLAlchemy 1.3 suddenly has problems with these test cases")
5560
@patch('crate.client.connection.Cursor', FakeCursor)
5661
class SqlAlchemyDateAndDateTimeTest(TestCase):
5762

tests/dict_test.py

+4-2
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,8 @@
2020
# software solely pursuant to the terms of the relevant commercial agreement.
2121

2222
from __future__ import absolute_import
23-
from unittest import TestCase
23+
24+
from unittest import TestCase, skipIf
2425
from unittest.mock import patch, MagicMock
2526

2627
import sqlalchemy as sa
@@ -31,7 +32,7 @@
3132
except ImportError:
3233
from sqlalchemy.ext.declarative import declarative_base
3334

34-
from sqlalchemy_cratedb import ObjectArray, ObjectType
35+
from sqlalchemy_cratedb import ObjectArray, ObjectType, SA_VERSION, SA_1_4
3536
from crate.client.cursor import Cursor
3637

3738

@@ -40,6 +41,7 @@
4041
FakeCursor.return_value = fake_cursor
4142

4243

44+
@skipIf(SA_VERSION < SA_1_4, "SQLAlchemy 1.3 suddenly has problems with these test cases")
4345
class SqlAlchemyDictTypeTest(TestCase):
4446

4547
def setUp(self):

tests/insert_from_select_test.py

+5-2
Original file line numberDiff line numberDiff line change
@@ -18,14 +18,16 @@
1818
# However, if you have executed another commercial license agreement
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.
21-
2221
from datetime import datetime
23-
from unittest import TestCase
22+
from unittest import TestCase, skipIf
2423
from unittest.mock import patch, MagicMock
2524

2625
import sqlalchemy as sa
2726
from sqlalchemy import select, insert
2827
from sqlalchemy.orm import Session
28+
29+
from sqlalchemy_cratedb import SA_VERSION, SA_1_4
30+
2931
try:
3032
from sqlalchemy.orm import declarative_base
3133
except ImportError:
@@ -40,6 +42,7 @@
4042
FakeCursor.return_value = fake_cursor
4143

4244

45+
@skipIf(SA_VERSION < SA_1_4, "SQLAlchemy 1.3 suddenly has problems with these test cases")
4346
class SqlAlchemyInsertFromSelectTest(TestCase):
4447

4548
def assertSQL(self, expected_str, actual_expr):

tests/update_test.py

+3-3
Original file line numberDiff line numberDiff line change
@@ -18,12 +18,11 @@
1818
# However, if you have executed another commercial license agreement
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.
21-
2221
from datetime import datetime
23-
from unittest import TestCase
22+
from unittest import TestCase, skipIf
2423
from unittest.mock import patch, MagicMock
2524

26-
from sqlalchemy_cratedb import ObjectType
25+
from sqlalchemy_cratedb import ObjectType, SA_VERSION, SA_1_4
2726

2827
import sqlalchemy as sa
2928
from sqlalchemy.orm import Session
@@ -41,6 +40,7 @@
4140
FakeCursor.return_value = fake_cursor
4241

4342

43+
@skipIf(SA_VERSION < SA_1_4, "SQLAlchemy 1.3 suddenly has problems with these test cases")
4444
class SqlAlchemyUpdateTest(TestCase):
4545

4646
def setUp(self):

0 commit comments

Comments
 (0)