-
-
Notifications
You must be signed in to change notification settings - Fork 2.8k
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
Docs: API for pytest_collect_file #2493
Comments
as far as i can tell all non-none results will be used, while some hooks use the furst result, this one ises all results |
Just to clarify this is the use case I'm talking about:
This works perfectly, but it uses non-public API by importing |
Oh wait... This works if I just to return (The code snippet I posted above actually processes the |
As @RonnyPfannschmidt mentioned, pytest will call So in summary you really should only check for def pytest_collect_file(path, parent):
if path.ext == '.yaml':
return YamlCollector(path=path, parent=parent) Pytest will gather all collectors returned by all plugins because even a That's what the example in https://docs.pytest.org/en/latest/example/nonpython.html does, btw. |
I misunderstood @RonnyPfannschmidt comment, now it makes sense! |
Should I make a PR to add basically your explanation to the docs, or is it good enough to have it here in this issue? And thanks =) |
A PR would be very welcome! 👍 |
Upon reading the docs more carefully, I realized that there's a very clear explanation here. The only thing I could add perhaps is to show the decorator |
Definitely, thanks! You will need to add that information in the docstring of each hook in hookspec.py. |
I'm not sure from reading the docs whether there is public API for
pytest_collect_file
that allows to fall back to the default collector. Would it be possible to clarify that?Specifically, I need to use custom code to process certain (non-python) test files; I can recognize them by their path pattern. However, any other files should be processed using normal pytest rules. This would be very easy if I could (under custom-defined conditions) return the default collector from
pytest_collect_file
.The text was updated successfully, but these errors were encountered: