Repository navigation
Replies: 1 comment
|
Hi @ElArkk There is no global pytest option that safely turns every collection-time That distinction is intentional: an import failure may mean an optional dependency is absent, but it may also mean your package is genuinely broken. Automatically converting both cases into skips could hide real failures. For an optional dependency, the supported approach is still: import pytest
optional_package = pytest.importorskip("optional_package")at module level, before importing code which requires it. Current pytest also has: but that only allows the rest of the test suite to continue. The import failure remains a collection error and the pytest run still fails; it does not turn the module into a skip. If an entire directory is only applicable when an optional dependency exists, another option is to exclude that directory during collection from So for optional dependencies where you want a proper Please mark this answer as accepted if it helped, thank you. |
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
I'm wondering whether there is a more high-level way of skipping whole test files due to failing imports than
pytest.importorskip.The reason that I'd need such a "global" option is twofold:
importorskip.importorskipfrom those hooks. As I need to putimportorskipbefore importing the dependencies that might fail due to those missing imports.All reactions