How to use pytest.mark.parametrize (or equivilant) inside a plugin #8893
-
I have a conftest.py file, that's duplicated across repos, so I'm trying to turn it into a plugin. It parses yml files for tests, then adds those tests to the overall suite, using "@pytest.mark.parametrize". This part works in conftest.py! When switching the code to the plugin, the parametrize function gets skipped completely. Is this expected? Is there a hook I can use to replicate the same behavior of adding tests? I saw the pytest_generate_tests hook, but it's called for each test_.py file, (not just once). I could maybe get it to skip unless it hits my custom test_.py, but I'm not sure how to get it to call on a test_.py inside my plugin. That also seems like a hacky answer, so I'm hoping there's a better one? Thanks in advance for any pointers on this! |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 2 replies
-
The best way I can find is to base it on this example here: https://docs.pytest.org/en/6.2.x/example/nonpython.html In the end, I couldn't find a way to use @pytest.mark.parametrize, but I'm not sure it's necessary here. |
Beta Was this translation helpful? Give feedback.
The best way I can find is to base it on this example here: https://docs.pytest.org/en/6.2.x/example/nonpython.html
There's a bit of the plugin I'm having to refactor to do so, but it's looking like it'll be cleaner in the end!
In the end, I couldn't find a way to use @pytest.mark.parametrize, but I'm not sure it's necessary here.