Integrate warnings filtering directly into Config (#7700)
Warnings are a central part of Python, so much that Python itself has command-line and environtment variables to handle warnings. By moving the concept of warning handling into Config, it becomes natural to filter warnings issued as early as possible, even before the "_pytest.warnings" plugin is given a chance to spring into action. This also avoids the weird coupling between config and the warnings plugin that was required before. Fix #6681 Fix #2891 Fix #7620 Fix #7626 Close #7649 Co-authored-by: Ran Benita <ran@unusedvar.com>
This commit is contained in:
@@ -30,18 +30,15 @@ def pytest_configure(config: Config) -> None:
|
||||
# of enabling faulthandler before each test executes.
|
||||
config.pluginmanager.register(FaultHandlerHooks(), "faulthandler-hooks")
|
||||
else:
|
||||
from _pytest.warnings import _issue_warning_captured
|
||||
|
||||
# Do not handle dumping to stderr if faulthandler is already enabled, so warn
|
||||
# users that the option is being ignored.
|
||||
timeout = FaultHandlerHooks.get_timeout_config_value(config)
|
||||
if timeout > 0:
|
||||
_issue_warning_captured(
|
||||
config.issue_config_time_warning(
|
||||
pytest.PytestConfigWarning(
|
||||
"faulthandler module enabled before pytest configuration step, "
|
||||
"'faulthandler_timeout' option ignored"
|
||||
),
|
||||
config.hook,
|
||||
stacklevel=2,
|
||||
)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user