]> git.ipfire.org Git - thirdparty/sqlalchemy/alembic.git/commitdiff
Support pytest 6.x
authorMike Bayer <mike_mp@zzzcomputing.com>
Sun, 27 Sep 2020 01:05:53 +0000 (21:05 -0400)
committerMike Bayer <mike_mp@zzzcomputing.com>
Mon, 28 Sep 2020 02:22:57 +0000 (22:22 -0400)
pytest has removed support for pytest.Class(..parent)
and we need to use from_parent.

Also works around new issue for 6.1.0

References: https://github.com/pytest-dev/pytest/issues/7807

Change-Id: Ia5fed9b22e76c99f71489283acee207f996f52a4

alembic/__init__.py
alembic/testing/plugin/pytestplugin.py
tox.ini

index 4bb932236a038e9608c26fffe674c6504674cbce..75dc7ded42371d935e0b695f3ee632ffb1e07f7f 100644 (file)
@@ -5,7 +5,7 @@ from . import op  # noqa
 from .runtime import environment
 from .runtime import migration
 
-__version__ = '1.4.4'
+__version__ = "1.4.4"
 
 sys.modules["alembic.migration"] = migration
 sys.modules["alembic.environment"] = environment
index 1c8be05a5383a44264701d450a92961f79ad76b4..ba3d35bbe1e6064273a037b7b078447ff45673cb 100644 (file)
@@ -33,16 +33,10 @@ 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)
-        # ]
+        ctor = getattr(pytest.Class, "from_parent", pytest.Class)
 
         return [
-            pytest.Class(parametrize_cls.__name__, parent=collector)
+            ctor(name=parametrize_cls.__name__, parent=collector)
             for parametrize_cls in _parametrize_cls(collector.module, obj)
         ]
     elif (
diff --git a/tox.ini b/tox.ini
index ed233eef5105f625d7496e6ff5c37ce888dab9a1..f1447547f1fc2c46afb02f25de2ade59e0dceda9 100644 (file)
--- a/tox.ini
+++ b/tox.ini
@@ -7,7 +7,7 @@ SQLA_REPO = {env:SQLA_REPO:git+https://github.com/sqlalchemy/sqlalchemy.git}
 [testenv]
 cov_args=--cov=alembic --cov-report term --cov-report xml
 
-deps=pytest!=3.9.1,!=3.9.2
+deps=pytest>4.6
      pytest-xdist
      mock
      sqla11: {[tox]SQLA_REPO}@rel_1_1
@@ -30,7 +30,7 @@ usedevelop=
 # only use --dropfirst option if we're *not* using -n;
 # if -n is used, we're working in brand new DBs anyway
 setenv=
-    BASECOMMAND=python -m pytest
+    BASECOMMAND=python -m pytest --rootdir {toxinidir}
     WORKERS=-n4
     sqla079: WORKERS=--dropfirst
     cov: COVERAGE={[testenv]cov_args}