-
Notifications
You must be signed in to change notification settings - Fork 31
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
QA: Add EOL/deprecation warning about support for SQLAlchemy 1.3
- Loading branch information
Showing
5 changed files
with
76 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
# -*- coding: utf-8; -*- | ||
import sys | ||
import warnings | ||
from unittest import TestCase, skipIf | ||
|
||
from crate.client.sqlalchemy import SA_1_4, SA_VERSION | ||
from crate.testing.util import ExtraAssertions | ||
|
||
|
||
class SqlAlchemyWarningsTest(TestCase, ExtraAssertions): | ||
|
||
@skipIf(SA_VERSION >= SA_1_4, "There is no deprecation warning for " | ||
"SQLAlchemy 1.3 on higher versions") | ||
def test_sa13_deprecation_warning(self): | ||
""" | ||
Verify that a `DeprecationWarning` is issued when running SQLAlchemy 1.3. | ||
https://docs.python.org/3/library/warnings.html#testing-warnings | ||
""" | ||
with warnings.catch_warnings(record=True) as w: | ||
|
||
# Cause all warnings to always be triggered. | ||
warnings.simplefilter("always") | ||
|
||
# Trigger a warning by importing the SQLAlchemy dialect module. | ||
# Because it already has been loaded, unload it beforehand. | ||
del sys.modules["crate.client.sqlalchemy"] | ||
import crate.client.sqlalchemy # noqa: F401 | ||
|
||
# Verify details of the SA13 EOL/deprecation warning. | ||
self.assertEqual(len(w), 1) | ||
self.assertIsSubclass(w[-1].category, DeprecationWarning) | ||
self.assertIn("SQLAlchemy 1.3 is effectively EOL.", str(w[-1].message)) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
class ExtraAssertions: | ||
""" | ||
Additional assert methods for unittest. | ||
- https://github.com/python/cpython/issues/71339 | ||
- https://bugs.python.org/issue14819 | ||
- https://bugs.python.org/file43047/extra_assertions.patch | ||
""" | ||
|
||
def assertIsSubclass(self, cls, superclass, msg=None): | ||
try: | ||
r = issubclass(cls, superclass) | ||
except TypeError: | ||
if not isinstance(cls, type): | ||
self.fail(self._formatMessage(msg, | ||
'%r is not a class' % (cls,))) | ||
raise | ||
if not r: | ||
self.fail(self._formatMessage(msg, | ||
'%r is not a subclass of %r' % (cls, superclass))) |