Skip to content

Instantly share code, notes, and snippets.

@tombasche
Last active July 20, 2018 20:28
Show Gist options
  • Save tombasche/8f0c3f92d2637b00b4228bc3aff64921 to your computer and use it in GitHub Desktop.
Save tombasche/8f0c3f92d2637b00b4228bc3aff64921 to your computer and use it in GitHub Desktop.
Simple function and test to show off hypothesis
import re
from hypothesis import given, strategies as st
EMAIL_REGEX = re.compile(r'[a-zA-Z0-9_.-]+@[a-zA-Z0-9-]+.[a-zA-Z0-9-.]+')
def validate_email(email):
""" Validates an email address"""
if EMAIL_REGEX.match(email):
return True
else:
return False
@given(email=st.emails())
def test_email_validation(email):
print(email)
assert validate_email(email) is True
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment