-
Notifications
You must be signed in to change notification settings - Fork 232
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Added tests for untested code #54
Open
mark0978
wants to merge
1
commit into
syrusakbary:master
Choose a base branch
from
mark0978:master
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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 |
---|---|---|
@@ -0,0 +1,59 @@ | ||
# encoding: utf-8 | ||
import unittest | ||
|
||
from validate_email import validate_email | ||
|
||
class AddressPatternTests(unittest.TestCase): | ||
|
||
def test_ascii_regular(self): | ||
self.assertTrue(validate_email(r'[email protected]')) | ||
self.assertTrue(validate_email(r'[email protected]')) | ||
self.assertTrue(validate_email(r'[email protected]')) | ||
|
||
self.assertFalse(validate_email(r'someone@gmail')) | ||
self.assertFalse(validate_email(r'someonegmail.com')) | ||
self.assertFalse(validate_email(r'@gmail.com')) | ||
self.assertFalse(validate_email(r'someone @gmail.com')) | ||
|
||
# All of the names below come from wikipedia: | ||
# https://en.wikipedia.org/wiki/International_email#Email_addresses | ||
|
||
def test_chinese_regular(self): | ||
self.assertTrue(validate_email(r'用户@例子.广告')) # Chinese | ||
|
||
self.assertFalse(validate_email(r'用户例子.广告')) # No @ | ||
self.assertFalse(validate_email(r'用户@例子广告')) # No . | ||
self.assertFalse(validate_email(r'用户@例子.')) # Nothing after the . | ||
self.assertFalse(validate_email(r'@例子.广告')) # Nothing before the @ | ||
|
||
def test_hindi_regular(self): | ||
self.assertTrue(validate_email(r'उपयोगकर्ता@उदाहरण.कॉम')) # Hindi | ||
|
||
self.assertFalse(validate_email(r'उपयोगकर्ताउदाहरण.कॉम')) # No @ | ||
self.assertFalse(validate_email(r'उपयोगकर्ता@उदाहरणकॉम')) # No . | ||
self.assertFalse(validate_email(r'उपयोगकर्ता@उदाहरण.')) # Nothing after the . | ||
self.assertFalse(validate_email(r'@उदाहरण.कॉम')) # Nothing before the @ | ||
|
||
def test_ukranian_regular(self): | ||
self.assertTrue(validate_email(r'юзер@екзампл.ком')) # Chinese | ||
|
||
self.assertFalse(validate_email(r'')) # No @ | ||
self.assertFalse(validate_email(r'')) # No . | ||
self.assertFalse(validate_email(r'')) # Nothing after the . | ||
self.assertFalse(validate_email(r'')) # Nothing before the @ | ||
|
||
def test_greek_regular(self): | ||
self.assertTrue(validate_email(r'θσερ@εχαμπλε.ψομ')) | ||
|
||
self.assertFalse(validate_email(r'θσερεχαμπλε.ψομ')) # No @ | ||
self.assertFalse(validate_email(r'θσερ@εχαμπλεψομ')) # No . | ||
self.assertFalse(validate_email(r'θσερ@εχαμπλε.')) # Nothing after the . | ||
self.assertFalse(validate_email(r'@εχαμπλε.ψομ')) # Nothing before the @ | ||
|
||
def test_german_regular(self): | ||
self.assertTrue(validate_email(r'Dörte@Sörensen.example.com')) | ||
|
||
self.assertFalse(validate_email(r'DörteSörensen.example.com')) # No @ | ||
self.assertFalse(validate_email(r'Dörte@Sörensenexamplecom')) # No . | ||
self.assertFalse(validate_email(r'Dörte@Sörensen.')) # Nothing after the . | ||
self.assertFalse(validate_email(r'@Sörensen.example.com')) # Nothing before the @ |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Does it pass locally for you? I'm testing it locally and this case is failing.