-
-
Notifications
You must be signed in to change notification settings - Fork 2.8k
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
Add note on sharing the slow
marker in the basic examples
#2653
Conversation
Hi @felipedau, thanks a lot for the PR. Looking at the code, I think it would be better to change the example itself to define the marker in a separate module (other than a conftest.py) instead of adding a note. What do you think? I also wonder if we should advertise using |
Alternatively we can rewrite the example to use a @RonnyPfannschmidt @hackebrot opinions? |
@nicoddemus we should finalize a plan for removal, its a bad hack |
Maybe it's because I am relatively new to pytest (well, to testing in general), but importing from another test module looks weird to me.
I think it sounds a lot more elegant :) |
@nicoddemus, I made the changes you suggested in the project I am currently working on and I think it looks a lot better! (AnemoneLabs/unmessage@f1a61fc) The problem is that it's still using I do not think we are talking just about a note here. Should I close this PR? Thanks! |
Hi @felipedau, sorry for not getting back to you sooner. I think we can rewrite this example from the docs: it is about how to skip tests based on a command line argument, not about using the Your version looks good, but I would simplify it a little bit like this: def pytest_addoption(parser):
parser.addoption('--runslow', action='store_true',
default=False, help="run slow tests")
def pytest_collection_modifyitems(config, items):
if config.getoption('--runslow'):
# --runslow given in cli: do not skip slow tests
return
skip_slow = pytest.mark.skip(reason='need --runslow option to run')
for item in items:
if 'slow' in item.keywords:
item.add_marker(skip_slow) Would you like to update the documentation to use this recipe? |
Don't worry. Not a problem at all :)
Thanks, it is indeed a lot simpler. I just made the update. I can fix/squash things, but I cannot rename the branch (otherwise it will close this PR). Is this okay or should I create a new one? Thanks! |
Thanks! Feel free to rebase/squash. I will review it first thing in the morning. 👍 |
28e9d35
to
acd3c4f
Compare
Alright! Thanks @nicoddemus, I learned new things with your sugggestions :) |
Thanks a lot @felipedau! |
Hi! I recently faced the same issue as in #472 when trying to reuse the
slow
marker and it took me a while to understand why that was failing. I figured that having this note would be useful. If someone agrees, I can go through the checklist to make it a proper PR.Question: in a similar issue (#1688) @nicoddemus said that "using
pytest.config
is discouraged". Is its use discouraged in that specific case or there is a better way to use the configs in general?Thanks!
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
;Make sure to include reasonable tests for your change if necessaryUnless your change is a trivial or a documentation fix (e.g., a typo or reword of a small section) please:
Add yourself toAUTHORS
;