Skip to content

Commit 6ac0a22

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 6ac0a22

File tree

5 files changed

+23
-10
lines changed

5 files changed

+23
-10
lines changed

tests/compiler_test.py

+1-2
Original file line numberDiff line numberDiff line change
@@ -289,8 +289,7 @@ def test_for_update(self):
289289
FakeCursor = MagicMock(name='FakeCursor', spec=Cursor)
290290

291291

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")
292+
@skipIf(SA_VERSION < SA_1_4, "SQLAlchemy 1.3 suddenly has problems with these test cases")
294293
class CompilerTestCase(TestCase):
295294
"""
296295
A base class for providing mocking infrastructure to validate the DDL compiler.

tests/datetime_test.py

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

2222
from __future__ import absolute_import
23+
24+
import sys
2325
from datetime import datetime, tzinfo, timedelta
24-
from unittest import TestCase
26+
from unittest import TestCase, skipIf
2527
from unittest.mock import patch, MagicMock
2628

2729
import sqlalchemy as sa
2830
from sqlalchemy.exc import DBAPIError
2931
from sqlalchemy.orm import Session
32+
33+
from sqlalchemy_cratedb import SA_VERSION, SA_1_4
34+
3035
try:
3136
from sqlalchemy.orm import declarative_base
3237
except ImportError:
@@ -52,6 +57,7 @@ def dst(self, date_time):
5257
return timedelta(seconds=-7200)
5358

5459

60+
@skipIf(SA_VERSION < SA_1_4, "SQLAlchemy 1.3 suddenly has problems with these test cases")
5561
@patch('crate.client.connection.Cursor', FakeCursor)
5662
class SqlAlchemyDateAndDateTimeTest(TestCase):
5763

tests/dict_test.py

+5-2
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,9 @@
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+
import sys
25+
from unittest import TestCase, skipIf
2426
from unittest.mock import patch, MagicMock
2527

2628
import sqlalchemy as sa
@@ -31,7 +33,7 @@
3133
except ImportError:
3234
from sqlalchemy.ext.declarative import declarative_base
3335

34-
from sqlalchemy_cratedb import ObjectArray, ObjectType
36+
from sqlalchemy_cratedb import ObjectArray, ObjectType, SA_VERSION, SA_1_4
3537
from crate.client.cursor import Cursor
3638

3739

@@ -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 SqlAlchemyDictTypeTest(TestCase):
4447

4548
def setUp(self):

tests/insert_from_select_test.py

+6-2
Original file line numberDiff line numberDiff line change
@@ -18,14 +18,17 @@
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-
21+
import sys
2222
from datetime import datetime
23-
from unittest import TestCase
23+
from unittest import TestCase, skipIf
2424
from unittest.mock import patch, MagicMock
2525

2626
import sqlalchemy as sa
2727
from sqlalchemy import select, insert
2828
from sqlalchemy.orm import Session
29+
30+
from sqlalchemy_cratedb import SA_VERSION, SA_1_4
31+
2932
try:
3033
from sqlalchemy.orm import declarative_base
3134
except ImportError:
@@ -40,6 +43,7 @@
4043
FakeCursor.return_value = fake_cursor
4144

4245

46+
@skipIf(SA_VERSION < SA_1_4, "SQLAlchemy 1.3 suddenly has problems with these test cases")
4347
class SqlAlchemyInsertFromSelectTest(TestCase):
4448

4549
def assertSQL(self, expected_str, actual_expr):

tests/update_test.py

+4-3
Original file line numberDiff line numberDiff line change
@@ -18,12 +18,12 @@
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-
21+
import sys
2222
from datetime import datetime
23-
from unittest import TestCase
23+
from unittest import TestCase, skipIf
2424
from unittest.mock import patch, MagicMock
2525

26-
from sqlalchemy_cratedb import ObjectType
26+
from sqlalchemy_cratedb import ObjectType, SA_VERSION, SA_1_4
2727

2828
import sqlalchemy as sa
2929
from sqlalchemy.orm import Session
@@ -41,6 +41,7 @@
4141
FakeCursor.return_value = fake_cursor
4242

4343

44+
@skipIf(SA_VERSION < SA_1_4, "SQLAlchemy 1.3 suddenly has problems with these test cases")
4445
class SqlAlchemyUpdateTest(TestCase):
4546

4647
def setUp(self):

0 commit comments

Comments
 (0)