-
-
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
Allow module level skip #2808
Allow module level skip #2808
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Great work!
Aside from my comments, we also need a changelog file.
_pytest/outcomes.py
Outdated
""" skip an executing test with the given message. Note: it's usually | ||
better to use the pytest.mark.skipif marker to declare a test to be | ||
skipped under certain conditions like mismatching platforms or | ||
dependencies. See the pytest_skipping plugin for details. | ||
|
||
:kwarg bool allow_module_level: allows this function to be called at | ||
module level, skipping the rest of the module. Default to False. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this needs to be indented otherwise tox -e docs
fails
_pytest/outcomes.py
Outdated
allow_module_level = kwargs.pop('allow_module_level', False) | ||
if kwargs: | ||
keys = [k for k in kwargs.keys()] | ||
raise TypeError('unexpected keyworkd arguments: {}'.format(keys)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Needs to use {0}
to work on Python 2.6:
raise TypeError('unexpected keyworkd arguments: {0}'.format(keys))
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
keyworkd -> keyword
This probably should go to the |
doc/en/skipping.rst
Outdated
|
||
|
||
.. code-block:: python | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
i do wonder if there is a better example for this (thats not looking like a skipif marker or a importorskip would already solve
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe using the use case from previous discussion ? Something like:
if not pytest.config.getoption('--custom-flag'):
pytest.skip('--custom-flag is missing, skipping tests', allow_module_level=True)
Should I close this and re-open targeting the features branch ? |
You can rebase on the |
0fb31f8
to
9824499
Compare
Is this |
Hmm |
nope |
actually i do, whole module skips should be ignored, collectrports have no when so at collect time we should never fold skips |
I see, thanks. Could you tell @georgeyk what should be changed then? I'm not sure what should be done with collectreports. And the error is happening at the end of the session, when we are about to show the terminal summary, not during collection:
|
correct - a skip in a collect-report is added to the skip stats, and such a stat shouldn't be folded in the display |
one solution could be to add a when property to collect reports another solution could be to just ignore them its not clear what has the best effect |
That was my first thought too, but after thinking some more I think it might make sense in some cases. For example, if (say) 3 whole modules are skipped for the same reason, it makes sense to fold it. In light of that it might make sense to just make a special case for it in |
Something like (untested): when = getattr(event, 'when', None) # might be a collection report
if when == 'setup' and 'skip' in keywords and 'pytestmark' not in keywords: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks @georgeyk, well done!
@nicoddemus Thank you all to support this great project. I hope to do more in the future! |
We really appreciate it, thanks! |
@RonnyPfannschmidt you think we can merge this? |
Work-in-progress fix for #2805
I need to update the PR with all contributing guideline recommendations, but a initial feedback would be good.
--//--
Thanks for submitting a PR, your contribution is really appreciated!
Here's a quick checklist that should be present in PRs:
$issue_id.$type
for example (588.bug)removal
,feature
,bugfix
,vendor
,doc
ortrivial
bugfix
,vendor
,doc
ortrivial
fixes, targetmaster
; for removals or features targetfeatures
;Unless your change is a trivial or a documentation fix (e.g., a typo or reword of a small section) please:
AUTHORS
;