-
-
Notifications
You must be signed in to change notification settings - Fork 402
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
test: add an --offline option to pytest #1555
Conversation
Before I dive into this—I like the idea—we might get some utility from a set of options:
This might be overkill, true. If it makes implementation easier we can do just the |
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.
LGTM. Needs only two things:
- rebasing to avoid merge conflicts introduced on
master
since this PR was opened - adding the
online
arg to the docstring of themodule.example
class
As discussed on IRC, my ideas for a more complicated setup we could use to separate online tests (that might fail) in CI will come in a future PR, possibly after getting bikeshedded first in a dedicated issue.
I can't resist correcting the commit message, which contains an incorrect call to request.get
. (Well, I guess it could be correct if the file does import requests as request
, but why would you do this…)
And since I'm already commenting on that, I can also point out that "This option skip all tests" is missing something—and you will instantly know what. 😀 (There's also "can not" -> "cannot"—using that in two-word form is very uncommon in present-day writing, but it's not wrong per se.)
I got reminded of this PR when I had trouble testing locally because some random website was inaccessible and/or very slow. @dgw I think this PR is becoming more and more important, since Travis can literally fails for the wrong reasons because of online-only tests. |
Hmm… @Exirel I think you did something weird in your last rebase. The commit is showing me as author, which can't be right. This code is all you. 😕 |
@dgw I've honestly no idea how or why. :| |
Usage: $ py.test --offline This option skips all tests that cannot be run offline, as they are marked as "online". Either from manual tag: import requests @pytest.mark.online def test_call_google(): requests.get('https://google.com') Or from a command example: @example('.title http://google.com', '[ Google ] - google.com', online=True) def title_command(bot, trigger): # ... This is especially useful for people like me who are always traveling and can't have access to a reliable Internet connection. This could be used by Travis to speed-up the test suite, and/or to make it more reliable. Existing online examples have been marked as such.
Yay |
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.
We'll talk about further enhancements to reduce false CI failures for a future PR. 😸
Usage:
This option skip all tests that can not be run offline, as they are marked as "online". Either from manual tag:
Or from a command example:
This is especially useful for people like me who are always traveling and can't have access to a reliable Internet connection.
Existing online examples have been marked as such.