GeezerVison is showing github.com — Allow module level skip by georgeyk · Pull Request #2808 · pytest-dev/pytest
Conversation
georgeyk
commented
Oct 1, 2017
•
edited
Loading
Uh oh!
There was an error while loading. Please reload this page.
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:
- Add a new news fragment into the changelog folder
- name it
$issue_id.$type for example (588.bug)
- if you don't have an issue_id change it to the pr id after creating the pr
- ensure type is one of
removal, feature, bugfix, vendor, doc or trivial
- Make sure to use full sentences with correct case and punctuation, for example: "Fix issue with non-ascii contents in doctest text files."
- Target: for
bugfix, vendor, doc or trivial fixes, target master; for removals or features target features;
- Make sure to include reasonable tests for your change if necessary
Unless your change is a trivial or a documentation fix (e.g., a typo or reword of a small section) please:
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
|

Coverage increased (+0.003%) to 92.235% when pulling 0fb31f8 on georgeyk:allow-module-level-skip into 6690b8a on pytest-dev:master.
|
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
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.
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
|
|
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
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
georgeyk reacted with thumbs up emoji
|
|
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))
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
georgeyk reacted with thumbs up emoji
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.
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
georgeyk and nicoddemus reacted with thumbs up emoji
|
This probably should go to the features branch.
|
nicoddemus reacted with thumbs up emoji
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
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
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
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)
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
|
Should I close this and re-open targeting the features branch ?
|
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
|
You can rebase on the features branch, push force to this branch and then edit the target branch of the PR here on GH to features.
|
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
|
Hmm folded_skips is relatively new I think. @RonnyPfannschmidt do you have a suggestion on how to proceed here?
|
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
|
actually i do, whole module skips should be ignored, collectrports have no when
so at collect time we should never fold skips
|
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
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:
Traceback (most recent call last):
File "/home/travis/build/pytest-dev/pytest/.tox/py36/lib/python3.6/site-packages/_pytest/pytester.py", line 744, in runpytest_inprocess
reprec = self.inline_run(*args, **kwargs)
File "/home/travis/build/pytest-dev/pytest/.tox/py36/lib/python3.6/site-packages/_pytest/pytester.py", line 717, in inline_run
ret = pytest.main(list(args), plugins=plugins)
File "/home/travis/build/pytest-dev/pytest/.tox/py36/lib/python3.6/site-packages/_pytest/config.py", line 59, in main
return config.hook.pytest_cmdline_main(config=config)
File "/home/travis/build/pytest-dev/pytest/.tox/py36/lib/python3.6/site-packages/pluggy.py", line 745, in __call__
return self._hookexec(self, self._nonwrappers + self._wrappers, kwargs)
File "/home/travis/build/pytest-dev/pytest/.tox/py36/lib/python3.6/site-packages/pluggy.py", line 339, in _hookexec
return self._inner_hookexec(hook, methods, kwargs)
File "/home/travis/build/pytest-dev/pytest/.tox/py36/lib/python3.6/site-packages/pluggy.py", line 334, in <lambda>
_MultiCall(methods, kwargs, hook.spec_opts).execute()
File "/home/travis/build/pytest-dev/pytest/.tox/py36/lib/python3.6/site-packages/pluggy.py", line 614, in execute
res = hook_impl.function(*args)
File "/home/travis/build/pytest-dev/pytest/.tox/py36/lib/python3.6/site-packages/_pytest/main.py", line 131, in pytest_cmdline_main
return wrap_session(config, _main)
File "/home/travis/build/pytest-dev/pytest/.tox/py36/lib/python3.6/site-packages/_pytest/main.py", line 125, in wrap_session
exitstatus=session.exitstatus)
File "/home/travis/build/pytest-dev/pytest/.tox/py36/lib/python3.6/site-packages/pluggy.py", line 745, in __call__
return self._hookexec(self, self._nonwrappers + self._wrappers, kwargs)
File "/home/travis/build/pytest-dev/pytest/.tox/py36/lib/python3.6/site-packages/pluggy.py", line 339, in _hookexec
return self._inner_hookexec(hook, methods, kwargs)
File "/home/travis/build/pytest-dev/pytest/.tox/py36/lib/python3.6/site-packages/pluggy.py", line 302, in __call__
return outcome.get_result()
File "/home/travis/build/pytest-dev/pytest/.tox/py36/lib/python3.6/site-packages/pluggy.py", line 279, in get_result
raise ex[1].with_traceback(ex[2])
File "/home/travis/build/pytest-dev/pytest/.tox/py36/lib/python3.6/site-packages/pluggy.py", line 265, in __init__
self.result = func()
File "/home/travis/build/pytest-dev/pytest/.tox/py36/lib/python3.6/site-packages/pluggy.py", line 300, in <lambda>
outcome = _CallOutcome(lambda: self.oldcall(hook, hook_impls, kwargs))
File "/home/travis/build/pytest-dev/pytest/.tox/py36/lib/python3.6/site-packages/pluggy.py", line 334, in <lambda>
_MultiCall(methods, kwargs, hook.spec_opts).execute()
File "/home/travis/build/pytest-dev/pytest/.tox/py36/lib/python3.6/site-packages/pluggy.py", line 613, in execute
return _wrapped_call(hook_impl.function(*args), self.execute)
File "/home/travis/build/pytest-dev/pytest/.tox/py36/lib/python3.6/site-packages/pluggy.py", line 250, in _wrapped_call
wrap_controller.send(call_outcome)
File "/home/travis/build/pytest-dev/pytest/.tox/py36/lib/python3.6/site-packages/_pytest/terminal.py", line 427, in pytest_sessionfinish
exitstatus=exitstatus)
File "/home/travis/build/pytest-dev/pytest/.tox/py36/lib/python3.6/site-packages/pluggy.py", line 745, in __call__
return self._hookexec(self, self._nonwrappers + self._wrappers, kwargs)
File "/home/travis/build/pytest-dev/pytest/.tox/py36/lib/python3.6/site-packages/pluggy.py", line 339, in _hookexec
return self._inner_hookexec(hook, methods, kwargs)
File "/home/travis/build/pytest-dev/pytest/.tox/py36/lib/python3.6/site-packages/pluggy.py", line 302, in __call__
return outcome.get_result()
File "/home/travis/build/pytest-dev/pytest/.tox/py36/lib/python3.6/site-packages/pluggy.py", line 279, in get_result
raise ex[1].with_traceback(ex[2])
File "/home/travis/build/pytest-dev/pytest/.tox/py36/lib/python3.6/site-packages/pluggy.py", line 265, in __init__
self.result = func()
File "/home/travis/build/pytest-dev/pytest/.tox/py36/lib/python3.6/site-packages/pluggy.py", line 300, in <lambda>
outcome = _CallOutcome(lambda: self.oldcall(hook, hook_impls, kwargs))
File "/home/travis/build/pytest-dev/pytest/.tox/py36/lib/python3.6/site-packages/pluggy.py", line 334, in <lambda>
_MultiCall(methods, kwargs, hook.spec_opts).execute()
File "/home/travis/build/pytest-dev/pytest/.tox/py36/lib/python3.6/site-packages/pluggy.py", line 614, in execute
res = hook_impl.function(*args)
File "/home/travis/build/pytest-dev/pytest/.tox/py36/lib/python3.6/site-packages/_pytest/skipping.py", line 291, in pytest_terminal_summary
show_skipped(terminalreporter, lines)
File "/home/travis/build/pytest-dev/pytest/.tox/py36/lib/python3.6/site-packages/_pytest/skipping.py", line 370, in show_skipped
fskips = folded_skips(skipped)
File "/home/travis/build/pytest-dev/pytest/.tox/py36/lib/python3.6/site-packages/_pytest/skipping.py", line 352, in folded_skips
if event.when == 'setup' and 'skip' in keywords and 'pytestmark' not in keywords:
AttributeError: 'CollectReport' object has no attribute 'when'
|
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
|
correct - a skip in a collect-report is added to the skip stats, and such a stat shouldn't be folded in the display
|
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
|
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
|
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
correct - a skip in a collect-report is added to the skip stats, and such a stat shouldn't be folded in the display
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 folded_skips.
|
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
|
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:
|
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
|

Coverage increased (+0.006%) to 92.506% when pulling 03ce0ad on georgeyk:allow-module-level-skip into d132c50 on pytest-dev:features.
|
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
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.
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
|
@nicoddemus Thank you all to support this great project. I hope to do more in the future!
|
nicoddemus reacted with thumbs up emoji
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
I hope to do more in the future!
We really appreciate it, thanks!
|
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
|

Coverage increased (+0.006%) to 92.506% when pulling 0668a6c on georgeyk:allow-module-level-skip into d132c50 on pytest-dev:features.
|
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Assignees
No one assigned
Milestone
No milestone
Development
Successfully merging this pull request may close these issues.
Uh oh!
There was an error while loading. Please reload this page.
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
|