mirror of
https://github.com/sqlalchemy/sqlalchemy.git
synced 2026-05-15 05:07:16 -04:00
aba3ab247d
The warnings plugin lets us set the filters up in the config, and as our filter requirements are now simple we can just set this up. additionally pytest now recommends pyproject.toml, since we fully include this now, let's move it there. the pytest logging plugin seems to not be any problem either at the moment, so re-enable that. if it becomes apparent whatever the problem was (which was probably that it was just surprising, or something) we can disable it again and comment what the reason was. Change-Id: Ia9715533b01f72aa5fdcf6a27ce75b76f829fa43
40 lines
1.0 KiB
Python
40 lines
1.0 KiB
Python
# testing/warnings.py
|
|
# Copyright (C) 2005-2022 the SQLAlchemy authors and contributors
|
|
# <see AUTHORS file>
|
|
#
|
|
# This module is part of SQLAlchemy and is released under
|
|
# the MIT License: https://www.opensource.org/licenses/mit-license.php
|
|
from . import assertions
|
|
from .. import exc as sa_exc
|
|
from ..exc import SATestSuiteWarning
|
|
from ..util.langhelpers import _warnings_warn
|
|
|
|
|
|
def warn_test_suite(message):
|
|
_warnings_warn(message, category=SATestSuiteWarning)
|
|
|
|
|
|
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.
|
|
|
|
"""
|
|
|
|
|
|
def assert_warnings(fn, warning_msgs, regex=False):
|
|
"""Assert that each of the given warnings are emitted by fn.
|
|
|
|
Deprecated. Please use assertions.expect_warnings().
|
|
|
|
"""
|
|
|
|
with assertions._expect_warnings(
|
|
sa_exc.SAWarning, warning_msgs, regex=regex
|
|
):
|
|
return fn()
|