diff options
author | Federico Caselli <cfederico87@gmail.com> | 2022-02-20 12:03:19 +0100 |
---|---|---|
committer | Mike Bayer <mike_mp@zzzcomputing.com> | 2022-02-21 10:20:22 -0500 |
commit | a02b0ef482075eb0b967c833c1bd3db677e561b2 (patch) | |
tree | e5f267915c071eedf7205bd800ba754f6cfb79b8 /lib/sqlalchemy/testing/warnings.py | |
parent | e120837b682a3a822c2dff136ad48b1ca9fb6ce2 (diff) | |
download | sqlalchemy-a02b0ef482075eb0b967c833c1bd3db677e561b2.tar.gz |
Revert SQLAlchemy warnings to warnings.py
Configuring the warning filters in pyproject breaks tests if
no sqlalchemy is installed in the env, since the filters are
processed before loading conftest. It also may interfere
with coverage.
Revises Ia9715533b01f72aa5fdcf6a27ce75b76f829fa43
aba3ab247da4628e4e7baf993702e2efaccbc547
Change-Id: I51448a6a014f31d3088dce54cd20d1e683500f8c
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): |