summaryrefslogtreecommitdiff
path: root/lib/sqlalchemy/testing/warnings.py
diff options
context:
space:
mode:
authormike bayer <mike_mp@zzzcomputing.com>2022-01-23 14:22:13 +0000
committerGerrit Code Review <gerrit@ci3.zzzcomputing.com>2022-01-23 14:22:13 +0000
commit33f71953fcdf3f3e9dd7a498f669010a56a3755d (patch)
tree55634cd126edaa9a2b1010ef2b3a43eee679b1a5 /lib/sqlalchemy/testing/warnings.py
parent8fa6a1b9cc86bf1a580bc0f30a02cd4028051cf4 (diff)
parentde0b4db838e26fe61953c7765f35d5b7be581646 (diff)
downloadsqlalchemy-33f71953fcdf3f3e9dd7a498f669010a56a3755d.tar.gz
Merge "dont use exception catches for warnings; modernize xdist detection" into main
Diffstat (limited to 'lib/sqlalchemy/testing/warnings.py')
-rw-r--r--lib/sqlalchemy/testing/warnings.py32
1 files changed, 15 insertions, 17 deletions
diff --git a/lib/sqlalchemy/testing/warnings.py b/lib/sqlalchemy/testing/warnings.py
index 34b23d675..1c2039602 100644
--- a/lib/sqlalchemy/testing/warnings.py
+++ b/lib/sqlalchemy/testing/warnings.py
@@ -11,8 +11,13 @@ from .. import exc as sa_exc
from ..util.langhelpers import _warnings_warn
-class SATestSuiteWarning(sa_exc.SAWarning):
- """warning for a condition detected during tests that is non-fatal"""
+class SATestSuiteWarning(Warning):
+ """warning for a condition detected during tests that is non-fatal
+
+ Currently outside of SAWarning so that we can work around tools like
+ Alembic doing the wrong thing with warnings.
+
+ """
def warn_test_suite(message):
@@ -22,28 +27,21 @@ def warn_test_suite(message):
def setup_filters():
"""Set global warning behavior for the test suite."""
+ # TODO: at this point we can use the normal pytest warnings plugin,
+ # if we decide the test suite can be linked to pytest only
+
+ origin = r"^(?:test|sqlalchemy)\..*"
+
warnings.filterwarnings(
"ignore", category=sa_exc.SAPendingDeprecationWarning
)
warnings.filterwarnings("error", category=sa_exc.SADeprecationWarning)
warnings.filterwarnings("error", category=sa_exc.SAWarning)
- warnings.filterwarnings("always", category=SATestSuiteWarning)
- # some selected deprecations...
- warnings.filterwarnings("error", category=DeprecationWarning)
- warnings.filterwarnings(
- "ignore", category=DeprecationWarning, message=r".*StopIteration"
- )
- warnings.filterwarnings(
- "ignore",
- category=DeprecationWarning,
- message=r".*inspect.get.*argspec",
- )
+ warnings.filterwarnings("always", category=SATestSuiteWarning)
warnings.filterwarnings(
- "ignore",
- category=DeprecationWarning,
- message="The loop argument is deprecated",
+ "error", category=DeprecationWarning, module=origin
)
try:
@@ -52,7 +50,7 @@ def setup_filters():
pass
else:
warnings.filterwarnings(
- "once", category=pytest.PytestDeprecationWarning
+ "once", category=pytest.PytestDeprecationWarning, module=origin
)