Skip to content

Commit

Permalink
Chore: Fix tests on Python 3.11 and SQLAlchemy 1.3, by skipping them
Browse files Browse the repository at this point in the history
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 <class 'tests.compiler_test.SqlAlchemyDDLCompilerTest.test_ddl_with_foreign_keys.<locals>.RootStore'> class after both dependent classes have been defined.
  • Loading branch information
amotl committed Jun 10, 2024
1 parent 8d8e732 commit 40dedc3
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 6 deletions.
9 changes: 8 additions & 1 deletion tests/datetime_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand All @@ -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):

Expand Down
8 changes: 6 additions & 2 deletions tests/dict_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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


Expand All @@ -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):
Expand Down
8 changes: 5 additions & 3 deletions tests/update_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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):
Expand Down

0 comments on commit 40dedc3

Please sign in to comment.