]> git.ipfire.org Git - thirdparty/sqlalchemy/alembic.git/commitdiff
Don't raise on pytest deprecation warnings
authorMike Bayer <mike_mp@zzzcomputing.com>
Thu, 12 Mar 2020 23:59:34 +0000 (19:59 -0400)
committerMike Bayer <mike_mp@zzzcomputing.com>
Fri, 13 Mar 2020 00:00:12 +0000 (20:00 -0400)
py.test 5.4.0 emits deprecation warnings for pytest.Class.
make sure we don't raise for these, and log the code that will
be used for 5.4.0 when we bump requirements.

Fixes: #668
Change-Id: I83e0402c4a6b2365a63b58d052c6989df3a37328

alembic/testing/plugin/plugin_base.py
alembic/testing/plugin/pytestplugin.py
docs/build/unreleased/668.rst [new file with mode: 0644]

index 953528235262c3f2b9b382554e9c1dbfa6cf3eb9..276bc56c63fe986813b851a967538ea7796c8cad 100644 (file)
@@ -11,10 +11,12 @@ import sys
 
 from sqlalchemy.testing.plugin.plugin_base import *  # noqa
 from sqlalchemy.testing.plugin.plugin_base import post
+from sqlalchemy.testing.plugin.plugin_base import post_begin as sqla_post_begin
 from sqlalchemy.testing.plugin.plugin_base import stop_test_class as sqla_stc
 
 py3k = sys.version_info >= (3, 0)
 
+
 if py3k:
 
     ABC = abc.ABC
@@ -24,6 +26,21 @@ else:
         __metaclass__ = abc.ABCMeta
 
 
+def post_begin():
+    sqla_post_begin()
+
+    import warnings
+
+    try:
+        import pytest
+    except ImportError:
+        pass
+    else:
+        warnings.filterwarnings(
+            "once", category=pytest.PytestDeprecationWarning
+        )
+
+
 # override selected SQLAlchemy pytest hooks with vendored functionality
 def stop_test_class(cls):
     sqla_stc(cls)
index d6efdf4cb0b795167933a3b324197030351fb618..1c8be05a5383a44264701d450a92961f79ad76b4 100644 (file)
@@ -33,6 +33,14 @@ def pytest_configure(config):
 def pytest_pycollect_makeitem(collector, name, obj):
 
     if inspect.isclass(obj) and plugin_base.want_class(name, obj):
+
+        # in pytest 5.4.0
+        # return [
+        #     pytest.Class.from_parent(collector,
+        # name=parametrize_cls.__name__)
+        #     for parametrize_cls in _parametrize_cls(collector.module, obj)
+        # ]
+
         return [
             pytest.Class(parametrize_cls.__name__, parent=collector)
             for parametrize_cls in _parametrize_cls(collector.module, obj)
diff --git a/docs/build/unreleased/668.rst b/docs/build/unreleased/668.rst
new file mode 100644 (file)
index 0000000..d44ab42
--- /dev/null
@@ -0,0 +1,7 @@
+.. change::
+    :tags: bug, tests
+    :tickets: 668
+
+    Fixed an issue that prevented the test suite from running with the
+    recently released py.test 5.4.0.
+