]> git.ipfire.org Git - thirdparty/sqlalchemy/sqlalchemy.git/commitdiff
Support pytest 6.x rel_1_1
authorMike Bayer <mike_mp@zzzcomputing.com>
Sun, 27 Sep 2020 15:33:26 +0000 (11:33 -0400)
committerMike Bayer <mike_mp@zzzcomputing.com>
Sun, 27 Sep 2020 15:33:26 +0000 (11:33 -0400)
pytest has removed support for pytest.Class().collect()
and we need to use from_parent.

Change-Id: Ia5fed9b22e76c99f71489283acee207f996f52a4

lib/sqlalchemy/testing/plugin/pytestplugin.py

index 75064ada4c37c13f0a65d299817c19bdceb8b4eb..10a54351b97c80a67ff0cc336933212e05f23ed0 100644 (file)
@@ -124,8 +124,9 @@ def pytest_collection_modifyitems(session, config, items):
             if sub_cls is not test_class.cls:
                 list_ = rebuilt_items[test_class.cls]
 
-                for inst in pytest.Class(
-                        sub_cls.__name__,
+                ctor = getattr(pytest.Class, "from_parent", pytest.Class)
+                for inst in ctor(
+                        name=sub_cls.__name__,
                         parent=test_class.parent.parent).collect():
                     list_.extend(inst.collect())
 
@@ -148,7 +149,8 @@ def pytest_collection_modifyitems(session, config, items):
 
 def pytest_pycollect_makeitem(collector, name, obj):
     if inspect.isclass(obj) and plugin_base.want_class(obj):
-        return pytest.Class(name, parent=collector)
+        ctor = getattr(pytest.Class, "from_parent", pytest.Class)
+        return ctor(name=name, parent=collector)
     elif inspect.isfunction(obj) and \
             isinstance(collector, pytest.Instance) and \
             plugin_base.want_method(collector.cls, obj):