Last active
August 29, 2015 14:11
-
-
Save billyshambrook/cdaf205dba5e1749c881 to your computer and use it in GitHub Desktop.
Example of py.test skip if
This file contains hidden or 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
import pytest | |
def is_connected(): | |
import socket | |
try: | |
host = socket.gethostbyname("www.google.com") | |
socket.create_connection((host, 80), 2) | |
return True | |
except: | |
pass | |
return False | |
@pytest.mark.skipif(not is_connected(), reason="Need an internet connection") | |
def test_connection(): | |
assert is_connected() | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment