summaryrefslogtreecommitdiff
path: root/lib/sqlalchemy/testing/plugin
diff options
context:
space:
mode:
authorMike Bayer <mike_mp@zzzcomputing.com>2022-01-21 18:46:37 -0500
committerMike Bayer <mike_mp@zzzcomputing.com>2022-01-22 19:17:10 -0500
commitde0b4db838e26fe61953c7765f35d5b7be581646 (patch)
tree89f9816c86dbf9eaec0406b6a9b8585e9b645a6c /lib/sqlalchemy/testing/plugin
parentd46a4c0326bd2e697794514b920e6727d5153324 (diff)
downloadsqlalchemy-de0b4db838e26fe61953c7765f35d5b7be581646.tar.gz
dont use exception catches for warnings; modernize xdist detection
Improvements to the test suite's integration with pytest such that the "warnings" plugin, if manually enabled, will not interfere with the test suite, such that third parties can enable the warnings plugin or make use of the ``-W`` parameter and SQLAlchemy's test suite will continue to pass. Additionally, modernized the detection of the "pytest-xdist" plugin so that plugins can be globally disabled using PYTEST_DISABLE_PLUGIN_AUTOLOAD=1 without breaking the test suite if xdist were still installed. Warning filters that promote deprecation warnings to errors are now localized to SQLAlchemy-specific warnings, or within SQLAlchemy-specific sources for general Python deprecation warnings, so that non-SQLAlchemy deprecation warnings emitted from pytest plugins should also not impact the test suite. Fixes: #7599 Change-Id: Ibcf09af25228d39ee5a943fda82d8a9302433726
Diffstat (limited to 'lib/sqlalchemy/testing/plugin')
-rw-r--r--lib/sqlalchemy/testing/plugin/pytestplugin.py19
1 files changed, 7 insertions, 12 deletions
diff --git a/lib/sqlalchemy/testing/plugin/pytestplugin.py b/lib/sqlalchemy/testing/plugin/pytestplugin.py
index 7a62ad008..2ae6730bb 100644
--- a/lib/sqlalchemy/testing/plugin/pytestplugin.py
+++ b/lib/sqlalchemy/testing/plugin/pytestplugin.py
@@ -13,16 +13,10 @@ import itertools
import operator
import os
import re
+import uuid
import pytest
-try:
- import xdist # noqa
-
- has_xdist = True
-except ImportError:
- has_xdist = False
-
def pytest_addoption(parser):
group = parser.getgroup("sqlalchemy")
@@ -75,6 +69,9 @@ def pytest_addoption(parser):
def pytest_configure(config):
+ if config.pluginmanager.hasplugin("xdist"):
+ config.pluginmanager.register(XDistHooks())
+
if hasattr(config, "workerinput"):
plugin_base.restore_important_follower_config(config.workerinput)
plugin_base.configure_follower(config.workerinput["follower_ident"])
@@ -148,10 +145,8 @@ def pytest_collection_finish(session):
collect_types.init_types_collection(filter_filename=_filter)
-if has_xdist:
- import uuid
-
- def pytest_configure_node(node):
+class XDistHooks:
+ def pytest_configure_node(self, node):
from sqlalchemy.testing import provision
from sqlalchemy.testing import asyncio
@@ -166,7 +161,7 @@ if has_xdist:
provision.create_follower_db, node.workerinput["follower_ident"]
)
- def pytest_testnodedown(node, error):
+ def pytest_testnodedown(self, node, error):
from sqlalchemy.testing import provision
from sqlalchemy.testing import asyncio