-
-
Notifications
You must be signed in to change notification settings - Fork 2.8k
Collect marked functions regardless of naming #6239
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
Hi @iwanb, Thanks for the suggestion! Personally I'm reluctant to add an alternative to test function collection that differs from what is common practice for years in pytest (and unittest). Do you have a good use case where the name convention is not good enough? |
It's mainly to avoid duplicating the "test_" (or other) prefix all over the place, which increases the length of the test IDs. In our case we already use a marker on pretty much all tests to add some metadata, so it's already clear that it's a test case. So I want to implement the third option in a plugin, but it's cumbersome to do currently. Thinking it over, the second and/or third option is probably the safest, as otherwise the automatic marking of testcases using a module-level Right now I'll probably just monkeypatch the |
I see, thanks for the explanation. I'm not against adding some hook which would allow this to be customized in a plugin, I still would rather not add an alternative to the pytest core for the above reasons though. |
Ok, I'll make a PR for the hook. |
Closing this as stale; I'd still accept a PR for the hook but I don't think we want it so much as to keep an issue around (cf #12465) |
This is just a suggestion, could a function/class be collected if it has a marker attached to it, even if it doesn't follow the function name filter?
I.e. add a
ismarkedfunction
, similar to theisnosetest
, here and inistestclass
:https://github.com/pytest-dev/pytest/blob/master/src/_pytest/python.py#L315
Alternative implementations:
istestfunction
andistestclass
methods into a pytest hook instead, so plugins can implement itThe text was updated successfully, but these errors were encountered: