Last active
July 20, 2018 20:28
-
-
Save tombasche/8f0c3f92d2637b00b4228bc3aff64921 to your computer and use it in GitHub Desktop.
Simple function and test to show off hypothesis
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 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