Skip to content

pytest ignores commad line argument when adding in pytest_cmdline_preparse #8591

@BeKl92

Description

@BeKl92

Pytest version 6.2.3:

This works:

def pytest_cmdline_preparse(args):
    args[:] = ["--verbose"] + args
    args[:] = ["--color=yes"] + args
    args[:] = ["--tb=short"] + args

This does not work (still show warning in command line)

def pytest_cmdline_preparse(args):
    args[:] = ["-W ignore::pytest.PytestUnknownMarkWarning"] + args
    args[:] = ["-W ignore::DeprecationWarning"] + args

calling pytest from command line and give "-W ignore::DeprecationWarning" it is working as expected (all DeprecationWarning will be ignored). But adding it to cmdline_preparse function nothing will be ignored.

The code above worked with pytest 5.0.0 as we have used it until upgrade.

Metadata

Metadata

Assignees

No one assigned

    Labels

    topic: configrelated to config handling, argument parsing and config filetype: 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