'What is the right way to test pytest markers?

What is the best way to (uni)test some custom pytest mark functionality?

E.g. we have a pytest.ini with some marks:

system1: run in system 1

system2: run in system 2

How should one go about and test that they are working as expected? Should one do something like:

@system1
def test_system_1():
   pass

@system2
def test_system_2():
   pass

And parse the pytest output in order to check which tests were executed when running e.g.:

pytest -m system1

pytest -m system2



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source