It is possible to detect if a mark has been excluded?
I use pytest to run some tests against an embedded target. For some of the test setups, I can control the supply power via an epdu.
For the setups with an epdu, I want to power down the test equipment when the test is finished.
For the setups without epdu the test is called with -m "not power"
, but here it is also crucial that the power_on
fixture will not try to communicate with the epdu.
@pytest.fixture(scope='session', autouse=True)
def power_on():
# TODO: just return it called with `-m "not power"`
power_on_test_equipment()
yield
power_off_test_equipment()
@pytest.mark.power_control
def test_something():
power_something_off()
What I found is request.keywords['power']
will be true if I run pytest with -m power
but will not exists if I run without the mark or with -m "not power"
, which is not really helpful for my scenario.
I can solve the problem using two markes, like `-m "no_power and not power", but it does not seem very elegant.