Skip to content

Allow multiple use of -m option #7229

@joaonc

Description

@joaonc

Looks like when we use -m more than once, only the last entry is used (on Linux/macOS, at least, haven't tested on Windows).

Ex:

pytest test_me.py -m x -m z
pytest test_me.py -m 'x or y' -m z

Both those examples will only run those tests with the mark z, b/c that's the last -m argument passed in. If we reverse the order, then the other marked tests will run.

Nowadays it's common for command line programs to take in multiple of the same arguments and they usually work in an additive way.
In this case, multiple -m usage would mean an or:

  • -m x -m z = -m 'x or z'
  • -m 'x or y' -m z = -m '(x or y) or z'

If this is not possible, then fail when using -m multiple times.

My use case is that I have a bash script that adds markers depending on arguments and environment variables and took me a while to figure this out.. having early failure would have saved a lot of time.

Metadata

Metadata

Assignees

No one assigned

    Labels

    topic: collectionrelated to the collection phasetype: enhancementnew feature or API change, should be merged into features branch

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions