Skip to content

Warning filters: ini files take precedence over -W command-line option #3946

@nicoddemus

Description

@nicoddemus

Considering a simple test which raises a warning and a pytest.ini file:

import warnings

def test_foo():
    warnings.warn(UserWarning('oh no'))
[pytest]
filterwarnings =
    error   

Running with $ pytest -W ignore still makes the warning an error. I believe this is a bug and command-line options should take precedence over ini-options.

(Follow-up from #3945).

In summary the current precedence order is:

  1. mark
  2. ini file
  3. cmdline option

IMHO this should be instead:

  1. mark
  2. cmdline option
  3. ini

Metadata

Metadata

Assignees

No one assigned

    Labels

    plugin: warningsrelated to the warnings builtin plugintype: bugproblem that needs to be addressed

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions