forked from move-coop/parsons
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
email parse depends on python patch version
- Loading branch information
1 parent
710532a
commit 22aec31
Showing
1 changed file
with
20 additions
and
3 deletions.
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 |
---|---|---|
|
@@ -2,10 +2,10 @@ | |
import json | ||
import os | ||
import requests_mock | ||
import email | ||
import unittest | ||
import shutil | ||
import base64 | ||
import email | ||
|
||
|
||
_dir = os.path.dirname(__file__) | ||
|
@@ -516,10 +516,27 @@ def test__validate_email_string(self): | |
{"email": "<[email protected]>", "expected": True}, | ||
{"email": "Sender [email protected]", "expected": False}, | ||
{"email": "Sender <sender2email.com>", "expected": False}, | ||
{"email": "Sender <sender@email,com>", "expected": True}, | ||
{"email": "Sender <sender+alias@email,com>", "expected": True}, | ||
] | ||
|
||
# The behavior of email.parseaddr depends on the python patch version | ||
# See https://github.com/python/cpython/issues/102988 | ||
# or associated changelogs, e.g. | ||
# https://docs.python.org/3.8/whatsnew/changelog.html#python-3-8-20-final | ||
if getattr(email.utils, "supports_strict_parsing", False): | ||
emails.extend( | ||
[ | ||
{"email": "Sender <sender@email,com>", "expected": False}, | ||
{"email": "Sender <sender+alias@email,com>", "expected": False}, | ||
] | ||
) | ||
else: | ||
emails.extend( | ||
[ | ||
{"email": "Sender <sender@email,com>", "expected": True}, | ||
{"email": "Sender <sender+alias@email,com>", "expected": True}, | ||
] | ||
) | ||
|
||
for e in emails: | ||
if e["expected"]: | ||
self.assertTrue(self.gmail._validate_email_string(e["email"])) | ||
|