-
-
Notifications
You must be signed in to change notification settings - Fork 2.7k
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
pytest began spuriously rejecting pytest.skip in modules in 3.x #2338
Comments
- pytest 3.x broke the mechanism we used to implement them: pytest-dev/pytest#2338 - The `--integration' command-line argument doesn't seem to work with `python -m pytest --pyargs cgpm'. (This problem is fixable.)
we made this change after people again and again would use however the use-case you present is also valid and i wonder if there is a reasonable way to compromise |
The I think we should just expose that via |
seems like this is a 2 line change + a 30 line test |
It would be nice if there were some way to skip the tests that works both in 2.x and 3.x, because I would like to ship our software to users who can run |
I see, but we don't plan to release a 2.10 release with that support, sorry. You can follow up the discussion that lead to this decision in #607. As a solution, you can easily provide this function for your users to use: import pytest
if pytest.__version__ > '3':
def skip_module(reason):
raise pytest.skip.Exception(reason, allow_module_level=True)
else:
def skip_module(reason):
pytest.skip(reason=reason) And then use that instead of the previous @riastradh-probcomp would you like to contribute the |
Closing in favor of #2805 |
In pytest 2.x, I used
pytest.skip('...')
to skip entire modules of tests that are not enabled by a command-line flag--integration
, which have additional import dependencies and take longer to load and run.This useful functionality was broken in pytest 3.x with commit d81f230, which makes
pytest.skip
simply crash in this case.I can't use
pytestmark = pytest.mark.skipif(...)
because the ensuing code contains imports that must be skipped as well or else pytest will fail trying to load the module -- in other words, I really do want to abort the rest of the module.How do I restore this useful functionality?
Example. In
conftest.py
:In
test_foo.py
:Output:
Thanks for submitting an issue!
Here's a quick checklist in what to include:
pip list
of the virtual environment you are usingThe text was updated successfully, but these errors were encountered: