[pytest-dev] Adding a marker to items that have a fixture
Craig de Stigter
craig.ds at gmail.com
Wed May 1 22:18:42 EDT 2019
Hi there
Not sure if I'm missing something in the docs. I'm trying to add a marker
to every test that's decorated with a given fixture. What I have currently
is this:
def pytest_itemcollected(item):
if 'solr' in item.fixturenames:
# so you can skip it with "-m 'not solr'"
item.add_marker('solr')
This sort of works ( the marker is present by the time the test runs), but
command-line filtering options (`-m 'not solr'`) don't filter based on it.
I guess this hook is running after those options have been consulted?
I also tried the same thing in pytest_collection_modifyitems, but that
happens later so is even less likely to work.
Is there an earlier hook where I can modify an item before the command line
filtering options are checked?
Thanks
Craig
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/pytest-dev/attachments/20190502/7772724a/attachment.html>
More information about the pytest-dev
mailing list