diff options
Diffstat (limited to 'lib/sqlalchemy/testing/warnings.py')
-rw-r--r-- | lib/sqlalchemy/testing/warnings.py | 15 |
1 files changed, 10 insertions, 5 deletions
diff --git a/lib/sqlalchemy/testing/warnings.py b/lib/sqlalchemy/testing/warnings.py index e82566be7..491b8b2cb 100644 --- a/lib/sqlalchemy/testing/warnings.py +++ b/lib/sqlalchemy/testing/warnings.py @@ -6,7 +6,10 @@ # the MIT License: https://www.opensource.org/licenses/mit-license.php from __future__ import annotations +import warnings + from . import assertions +from .. import exc from .. import exc as sa_exc from ..exc import SATestSuiteWarning from ..util.langhelpers import _warnings_warn @@ -19,13 +22,15 @@ def warn_test_suite(message): def setup_filters(): """hook for setting up warnings filters. - Note that when the pytest warnings plugin is in place, that plugin - overwrites whatever happens here. - - Current SQLAlchemy 2.0 default is to use pytest warnings plugin - which is configured in pyproject.toml. + SQLAlchemy-specific classes must only be here and not in pytest config, + as we need to delay importing SQLAlchemy until conftest.py has been + processed. """ + warnings.filterwarnings("ignore", category=exc.SAPendingDeprecationWarning) + warnings.filterwarnings("error", category=exc.SADeprecationWarning) + warnings.filterwarnings("error", category=exc.SAWarning) + warnings.filterwarnings("always", category=exc.SATestSuiteWarning) def assert_warnings(fn, warning_msgs, regex=False): |