-
-
Notifications
You must be signed in to change notification settings - Fork 2.8k
CollectError instead of ImportError pytest 3.0.x #2010
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 @sashkab, Thanks for the feedback!
You mean
That's certainly a possibility, although I'm not sure why you need it in the code snipped you posted: import pytest
from _pytest.main import Collector
try:
from module import a, b, c
except (ImportError, Collector.CollectError):
pytestmark = pytest.mark.skip('Requires module.') Why not only catching |
i suppose we should just add a reason argument to importorskip then it can be called before the normal imports just fine |
It seems pytest catched
No, I meant test collector should not raise |
This seems really unlikely... unless some of the modules in there are executing We are hoping to introduce a flag to allow I'm closing this for now, feel free to follow up with more questions if you have any. |
I have multi-platform package, which has subset of modules which are required to run on one platform and they can be skipped on another platform. I've come up with the code which worked perfectly fine when I used 2.9.2:
I would get an error that module is required and tests will be skipped. Now, in pytest 3.0.3 I can't use this, because #1520 made ImportError no longer work and this code becomes
This is import error, and I have everything to handle it.
What I propose:
Raise
ImportError
instead ofCollectError
, or simplify use of theCollectError
by importing it into pytest (i.e.pytest.CollectError
).NB: I know I can use
pytest.importorskip('module')
, but it doesn't workfrom pytest.importorskip('module') import a, b, c
. Another reason why I don't use importorskip -- I can't provide reason.The text was updated successfully, but these errors were encountered: