GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — Allow module level skip by georgeyk · Pull Request #2808 · pytest-dev/pytest

Conversation

@georgeyk

@georgeyk georgeyk commented Oct 1, 2017 •
edited
Loading

Uh oh!

There was an error while loading. Please reload this page.

Copy link
Copy Markdown
Contributor

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:

  • Add yourself to AUTHORS;

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
@coveralls

coveralls commented Oct 1, 2017

Copy link
Copy Markdown

Coverage Status

Coverage increased (+0.003%) to 92.235% when pulling 0fb31f8 on georgeyk:allow-module-level-skip into 6690b8a on pytest-dev:master.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

nicoddemus
nicoddemus reviewed Oct 1, 2017
View reviewed changes

@nicoddemus nicoddemus left a comment

Copy link
Copy Markdown
Member

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.

All reactions
Comment thread _pytest/outcomes.py Outdated
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.

@nicoddemus nicoddemus Oct 1, 2017

Copy link
Copy Markdown
Member

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
All reactions
  • 👍 1 reaction
Comment thread _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))

@nicoddemus nicoddemus Oct 1, 2017

Copy link
Copy Markdown
Member

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
All reactions
  • 👍 1 reaction

@The-Compiler The-Compiler Oct 2, 2017

Copy link
Copy Markdown
Member

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

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

georgeyk and nicoddemus reacted with thumbs up emoji
All reactions
  • 👍 2 reactions
@The-Compiler

The-Compiler commented Oct 2, 2017

Copy link
Copy Markdown
Member

This probably should go to the features branch.

nicoddemus reacted with thumbs up emoji
All reactions
  • 👍 1 reaction

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

RonnyPfannschmidt
RonnyPfannschmidt reviewed Oct 2, 2017
View reviewed changes
Comment thread doc/en/skipping.rst


.. code-block:: python

@RonnyPfannschmidt RonnyPfannschmidt Oct 2, 2017

Copy link
Copy Markdown
Member

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.

All reactions

@georgeyk georgeyk Oct 2, 2017

Copy link
Copy Markdown
Contributor Author

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.

All reactions
@georgeyk

georgeyk commented Oct 2, 2017

Copy link
Copy Markdown
Contributor Author

Should I close this and re-open targeting the features branch ?

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@nicoddemus

nicoddemus commented Oct 2, 2017

Copy link
Copy Markdown
Member

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.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

georgeyk added 6 commits October 2, 2017 21:07
@georgeyk
Add allow_module_level kwarg to skip helper
79d3353
@georgeyk
Add initial tests using skip with allow_module_level kwarg
06307be
@georgeyk
Update skipping documentation to include usage of allow_module_level …
e4a6e52
…kwarg
@georgeyk
Fix docstring alignment and typos
c1aa63c
@georgeyk
Update documentation example of pytest.skip(allow_module_level=True)
59f6693
@georgeyk
Add 2808.feature changelog entry
9824499
@georgeyk
georgeyk force-pushed the allow-module-level-skip branch from 0fb31f8 to 9824499 Compare October 3, 2017 00:27
@georgeyk
georgeyk changed the base branch from master to features October 3, 2017 00:27
@georgeyk

georgeyk commented Oct 3, 2017

Copy link
Copy Markdown
Contributor Author

Is this event.when supposed to exist in CollectReport instance ? https://github.com/pytest-dev/pytest/blob/features/_pytest/skipping.py#L352

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@nicoddemus

nicoddemus commented Oct 3, 2017

Copy link
Copy Markdown
Member

Hmm folded_skips is relatively new I think. @RonnyPfannschmidt do you have a suggestion on how to proceed here?

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@RonnyPfannschmidt

RonnyPfannschmidt commented Oct 4, 2017

Copy link
Copy Markdown
Member

nope

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@RonnyPfannschmidt

RonnyPfannschmidt commented Oct 4, 2017

Copy link
Copy Markdown
Member

actually i do, whole module skips should be ignored, collectrports have no when

so at collect time we should never fold skips

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@nicoddemus

nicoddemus commented Oct 4, 2017

Copy link
Copy Markdown
Member

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'
All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@RonnyPfannschmidt

RonnyPfannschmidt commented Oct 4, 2017

Copy link
Copy Markdown
Member

correct - a skip in a collect-report is added to the skip stats, and such a stat shouldn't be folded in the display

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@RonnyPfannschmidt

RonnyPfannschmidt commented Oct 4, 2017

Copy link
Copy Markdown
Member

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

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@nicoddemus

nicoddemus commented Oct 4, 2017

Copy link
Copy Markdown
Member

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.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@nicoddemus

nicoddemus commented Oct 4, 2017

Copy link
Copy Markdown
Member

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:
All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@georgeyk
Fix: handle CollectReport in folded_skips function
03ce0ad
@coveralls

coveralls commented Oct 4, 2017

Copy link
Copy Markdown

Coverage Status

Coverage increased (+0.006%) to 92.506% when pulling 03ce0ad on georgeyk:allow-module-level-skip into d132c50 on pytest-dev:features.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

nicoddemus
nicoddemus approved these changes Oct 4, 2017
View reviewed changes

@nicoddemus nicoddemus left a comment

Copy link
Copy Markdown
Member

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!

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
@georgeyk

georgeyk commented Oct 4, 2017

Copy link
Copy Markdown
Contributor Author

@nicoddemus Thank you all to support this great project. I hope to do more in the future!

nicoddemus reacted with thumbs up emoji
All reactions
  • 👍 1 reaction

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@nicoddemus

nicoddemus commented Oct 4, 2017

Copy link
Copy Markdown
Member

I hope to do more in the future!

We really appreciate it, thanks!

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@georgeyk
Add myself to authors file
0668a6c
@coveralls

coveralls commented Oct 5, 2017

Copy link
Copy Markdown

Coverage Status

Coverage increased (+0.006%) to 92.506% when pulling 0668a6c on georgeyk:allow-module-level-skip into d132c50 on pytest-dev:features.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@nicoddemus

nicoddemus commented Oct 11, 2017

Copy link
Copy Markdown
Member

@RonnyPfannschmidt you think we can merge this?

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@RonnyPfannschmidt
RonnyPfannschmidt merged commit df37cdf into pytest-dev:features Oct 12, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Reviewers

@RonnyPfannschmidt RonnyPfannschmidt RonnyPfannschmidt left review comments
@The-Compiler The-Compiler The-Compiler left review comments
@nicoddemus nicoddemus nicoddemus approved these changes

Uh oh!

There was an error while loading. Please reload this page.

Assignees

No one assigned

Labels

None yet

Projects

None yet

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.

5 participants

@georgeyk @coveralls @The-Compiler @nicoddemus @RonnyPfannschmidt
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.
You are visitor 01402775 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.