diff options
author | Bruno Oliveira <nicoddemus@gmail.com> | 2020-09-04 11:57:15 -0300 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-09-04 11:57:15 -0300 |
commit | 19e99ab4131fbd709ce0e5a17694e1be3b22f355 (patch) | |
tree | 2ce2373f2c49b3894a2e1ba2e9e99e1c80e2cec4 /src/_pytest/main.py | |
parent | 91dbdb60930e1b573de366cbe7be6dac77ba200f (diff) | |
download | pytest-19e99ab4131fbd709ce0e5a17694e1be3b22f355.tar.gz |
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>
Diffstat (limited to 'src/_pytest/main.py')
-rw-r--r-- | src/_pytest/main.py | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/src/_pytest/main.py b/src/_pytest/main.py index 29b1e5f70..4ab91f82c 100644 --- a/src/_pytest/main.py +++ b/src/_pytest/main.py @@ -69,6 +69,20 @@ def pytest_addoption(parser: Parser) -> None: const=1, help="exit instantly on first error or failed test.", ) + group = parser.getgroup("pytest-warnings") + group.addoption( + "-W", + "--pythonwarnings", + action="append", + help="set which warnings to report, see -W option of python itself.", + ) + parser.addini( + "filterwarnings", + type="linelist", + help="Each line specifies a pattern for " + "warnings.filterwarnings. " + "Processed after -W/--pythonwarnings.", + ) group._addoption( "--maxfail", metavar="num", |