From: Mike Bayer Date: Thu, 12 Mar 2020 23:59:34 +0000 (-0400) Subject: Don't raise on pytest deprecation warnings X-Git-Tag: rel_1_4_2~8 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=d2457c772128fdf0a94084feaaa2844387d92c2b;p=thirdparty%2Fsqlalchemy%2Falembic.git Don't raise on pytest deprecation warnings 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 --- diff --git a/alembic/testing/plugin/plugin_base.py b/alembic/testing/plugin/plugin_base.py index 95352823..276bc56c 100644 --- a/alembic/testing/plugin/plugin_base.py +++ b/alembic/testing/plugin/plugin_base.py @@ -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) diff --git a/alembic/testing/plugin/pytestplugin.py b/alembic/testing/plugin/pytestplugin.py index d6efdf4c..1c8be05a 100644 --- a/alembic/testing/plugin/pytestplugin.py +++ b/alembic/testing/plugin/pytestplugin.py @@ -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 index 00000000..d44ab42f --- /dev/null +++ b/docs/build/unreleased/668.rst @@ -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. +