Skip to content

Commit

Permalink
Support pytest 6.x
Browse files Browse the repository at this point in the history
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: pytest-dev/pytest#7807

Change-Id: Ia5fed9b22e76c99f71489283acee207f996f52a4
  • Loading branch information
zzzeek committed Sep 28, 2020
1 parent bcc3c1a commit 8690940
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 11 deletions.
2 changes: 1 addition & 1 deletion alembic/__init__.py
Expand Up @@ -5,7 +5,7 @@
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
10 changes: 2 additions & 8 deletions alembic/testing/plugin/pytestplugin.py
Expand Up @@ -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 (
Expand Down
4 changes: 2 additions & 2 deletions tox.ini
Expand Up @@ -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
Expand All @@ -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}
Expand Down

0 comments on commit 8690940

Please sign in to comment.