Skip to content

Commit

Permalink
Disabling 'warnings' plugin also disables config time warnings
Browse files Browse the repository at this point in the history
  • Loading branch information
nicoddemus committed Sep 3, 2020
1 parent 340cea2 commit f188d97
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 0 deletions.
2 changes: 2 additions & 0 deletions src/_pytest/config/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -1235,6 +1235,8 @@ def issue_config_time_warning(self, warning: Warning, stacklevel: int) -> None:
:param warning: The warning instance.
:param stacklevel: stacklevel forwarded to warnings.warn.
"""
if self.pluginmanager.is_blocked("warnings"):
return

cmdline_filters = self.known_args_namespace.pythonwarnings or []
config_filters = self.getini("filterwarnings")
Expand Down
18 changes: 18 additions & 0 deletions testing/test_config.py
Original file line number Diff line number Diff line change
Expand Up @@ -275,6 +275,24 @@ def test_silence_unknown_key_warning(self, testdir: Testdir) -> None:
result = testdir.runpytest()
result.stdout.no_fnmatch_line("*PytestConfigWarning*")

@pytest.mark.filterwarnings("default")
def test_disable_warnings_plugin_disables_config_warnings(
self, testdir: Testdir
) -> None:
"""Disabling 'warnings' plugin also disables config time warnings"""
testdir.makeconftest(
"""
import pytest
def pytest_configure(config):
config.issue_config_time_warning(
pytest.PytestConfigWarning("custom config warning"),
stacklevel=2,
)
"""
)
result = testdir.runpytest("-pno:warnings")
result.stdout.no_fnmatch_line("*PytestConfigWarning*")

@pytest.mark.parametrize(
"ini_file_text, exception_text",
[
Expand Down

0 comments on commit f188d97

Please sign in to comment.