Skip to content

Instantly share code, notes, and snippets.

@billyshambrook
Last active August 29, 2015 14:11
Show Gist options
  • Save billyshambrook/cdaf205dba5e1749c881 to your computer and use it in GitHub Desktop.
Save billyshambrook/cdaf205dba5e1749c881 to your computer and use it in GitHub Desktop.
Example of py.test skip if
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