From 40dedc3d2b116ab2c580c0539216d5f467045ad6 Mon Sep 17 00:00:00 2001 From: Andreas Motl Date: Mon, 10 Jun 2024 14:30:14 +0200 Subject: [PATCH] Chore: Fix tests on Python 3.11 and 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'). If this is a class name, consider adding this relationship() to the .RootStore'> class after both dependent classes have been defined. --- tests/datetime_test.py | 9 ++++++++- tests/dict_test.py | 8 ++++++-- tests/update_test.py | 8 +++++--- 3 files changed, 19 insertions(+), 6 deletions(-) diff --git a/tests/datetime_test.py b/tests/datetime_test.py index 07e98ede..c951f87c 100644 --- a/tests/datetime_test.py +++ b/tests/datetime_test.py @@ -20,13 +20,18 @@ # software solely pursuant to the terms of the relevant commercial agreement. from __future__ import absolute_import + +import sys from datetime import datetime, tzinfo, timedelta -from unittest import TestCase +from unittest import TestCase, skipIf from unittest.mock import patch, MagicMock import sqlalchemy as sa from sqlalchemy.exc import DBAPIError from sqlalchemy.orm import Session + +from sqlalchemy_cratedb import SA_VERSION, SA_1_4 + try: from sqlalchemy.orm import declarative_base except ImportError: @@ -52,6 +57,8 @@ def dst(self, date_time): return timedelta(seconds=-7200) +@skipIf(SA_VERSION < SA_1_4 and (3, 11) <= sys.version_info < (3, 12), + "SQLAlchemy 1.3 has problems with these test cases on Python 3.11") @patch('crate.client.connection.Cursor', FakeCursor) class SqlAlchemyDateAndDateTimeTest(TestCase): diff --git a/tests/dict_test.py b/tests/dict_test.py index 84b6f491..2a301547 100644 --- a/tests/dict_test.py +++ b/tests/dict_test.py @@ -20,7 +20,9 @@ # software solely pursuant to the terms of the relevant commercial agreement. from __future__ import absolute_import -from unittest import TestCase + +import sys +from unittest import TestCase, skipIf from unittest.mock import patch, MagicMock import sqlalchemy as sa @@ -31,7 +33,7 @@ except ImportError: from sqlalchemy.ext.declarative import declarative_base -from sqlalchemy_cratedb import ObjectArray, ObjectType +from sqlalchemy_cratedb import ObjectArray, ObjectType, SA_VERSION, SA_1_4 from crate.client.cursor import Cursor @@ -40,6 +42,8 @@ FakeCursor.return_value = fake_cursor +@skipIf(SA_VERSION < SA_1_4 and (3, 11) <= sys.version_info < (3, 12), + "SQLAlchemy 1.3 has problems with these test cases on Python 3.11") class SqlAlchemyDictTypeTest(TestCase): def setUp(self): diff --git a/tests/update_test.py b/tests/update_test.py index 5062f229..d2a1567e 100644 --- a/tests/update_test.py +++ b/tests/update_test.py @@ -18,12 +18,12 @@ # However, if you have executed another commercial license agreement # with Crate these terms will supersede the license and you may use the # software solely pursuant to the terms of the relevant commercial agreement. - +import sys from datetime import datetime -from unittest import TestCase +from unittest import TestCase, skipIf from unittest.mock import patch, MagicMock -from sqlalchemy_cratedb import ObjectType +from sqlalchemy_cratedb import ObjectType, SA_VERSION, SA_1_4 import sqlalchemy as sa from sqlalchemy.orm import Session @@ -41,6 +41,8 @@ FakeCursor.return_value = fake_cursor +@skipIf(SA_VERSION < SA_1_4 and (3, 11) <= sys.version_info < (3, 12), + "SQLAlchemy 1.3 has problems with these test cases on Python 3.11") class SqlAlchemyUpdateTest(TestCase): def setUp(self):