Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to I dynamically add a pytest marker with my own pytest classes?

Tags:

python

pytest

I want to add some manual markers to the discovered tests I am doing at https://github.com/pycontribs/pytest-molecule/blob/master/pytest_molecule/init.py#L53

Mainly I want to conditionally add the "foo" mark so some of the discovered tests but I was not able to find any documentation on how to do it with classes based on pytest.Item .

like image 403
sorin Avatar asked Oct 21 '25 03:10

sorin


1 Answers

Nevermid, I found:

    self.add_marker('foo')

This works because Item inherits Node which has this method.

like image 148
sorin Avatar answered Oct 23 '25 16:10

sorin



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!