-
-
Notifications
You must be signed in to change notification settings - Fork 402
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
test: add an --offline option to pytest
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.
- Loading branch information
Showing
7 changed files
with
53 additions
and
12 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,19 @@ | ||
import pytest | ||
|
||
# This file lists files which should be ignored by pytest | ||
collect_ignore = ["setup.py", "sopel.py", "sopel/modules/ipython.py"] | ||
|
||
|
||
def pytest_addoption(parser): | ||
parser.addoption('--offline', action='store_true', default=False) | ||
|
||
|
||
def pytest_collection_modifyitems(config, items): | ||
if not config.getoption('--offline'): | ||
# nothing to skip | ||
return | ||
|
||
skip_online = pytest.mark.skip(reason='deactivated when --offline is used') | ||
for item in items: | ||
if 'online' in item.keywords: | ||
item.add_marker(skip_online) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters