]> git.ipfire.org Git - thirdparty/sqlalchemy/sqlalchemy.git/commitdiff
Dont raise on pytest deprecation warnings
authorMike Bayer <mike_mp@zzzcomputing.com>
Thu, 12 Mar 2020 23:44:37 +0000 (19:44 -0400)
committerMike Bayer <mike_mp@zzzcomputing.com>
Thu, 12 Mar 2020 23:50:56 +0000 (19:50 -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: #5201
Change-Id: I83e0402c4a6b2365a63b58d052c6989df3a37328
(cherry picked from commit be26fd13c124d5d53496cca98ce371c45c07c205)

doc/build/changelog/unreleased_13/5201.rst [new file with mode: 0644]
lib/sqlalchemy/testing/plugin/pytestplugin.py
lib/sqlalchemy/testing/warnings.py

diff --git a/doc/build/changelog/unreleased_13/5201.rst b/doc/build/changelog/unreleased_13/5201.rst
new file mode 100644 (file)
index 0000000..45ec9db
--- /dev/null
@@ -0,0 +1,7 @@
+.. change::
+    :tags: bug, tests
+    :tickets: 5201
+
+    Fixed an issue that prevented the test suite from running with the
+    recently released py.test 5.4.0.
+
index 6e958ab5e199b3c7b1a802638dacc2c1a24e5467..2c2cc398e80d440a5bd48ddb8651319b990049fb 100644 (file)
@@ -162,6 +162,11 @@ def pytest_collection_modifyitems(session, config, items):
             if sub_cls is not test_class.cls:
                 per_cls_dict = rebuilt_items[test_class.cls]
 
+                # in pytest 5.4.0
+                # for inst in pytest.Class.from_parent(
+                #     test_class.parent.parent, name=sub_cls.__name__
+                # ).collect():
+
                 for inst in pytest.Class(
                     sub_cls.__name__, parent=test_class.parent.parent
                 ).collect():
@@ -190,6 +195,14 @@ def pytest_collection_modifyitems(session, config, items):
 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)
index 36241185176ae457a5ef3c3c779aca5d5c6f23d3..6bb89a3cf85b318695504f8e5eb08fa5d66a123a 100644 (file)
@@ -38,6 +38,15 @@ def setup_filters():
         "ignore", category=DeprecationWarning, message=".*inspect.getargspec"
     )
 
+    try:
+        import pytest
+    except ImportError:
+        pass
+    else:
+        warnings.filterwarnings(
+            "once", category=pytest.PytestDeprecationWarning
+        )
+
 
 def assert_warnings(fn, warning_msgs, regex=False):
     """Assert that each of the given warnings are emitted by fn.