forked from python/cpython
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
2 changed files
with
58 additions
and
12 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
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 |
---|---|---|
|
@@ -3638,6 +3638,19 @@ def test_mime_classes_policy_argument(self): | |
m = cls(*constructor, policy=email.policy.default) | ||
self.assertIs(m.policy, email.policy.default) | ||
|
||
def test_iter_escaped_chars(self): | ||
self.assertEqual(list(utils._iter_escaped_chars(r'a\\b\"c\\"d')), | ||
[(0, 'a'), | ||
(2, '\\\\'), | ||
(3, 'b'), | ||
(5, '\\"'), | ||
(6, 'c'), | ||
(8, '\\\\'), | ||
(9, '"'), | ||
(10, 'd')]) | ||
self.assertEqual(list(utils._iter_escaped_chars('a\\')), | ||
[(0, 'a'), (1, '\\')]) | ||
|
||
def test_strip_quoted_realnames(self): | ||
def check(addr, expected): | ||
self.assertEqual(utils._strip_quoted_realnames(addr), expected) | ||
|
@@ -3646,9 +3659,19 @@ def check(addr, expected): | |
'Jane Doe <[email protected]>, John Doe <[email protected]>') | ||
check('"Jane Doe" <[email protected]>, "John Doe" <[email protected]>', | ||
' <[email protected]>, <[email protected]>') | ||
check(r'"Jane \"Doe"." <[email protected]>', | ||
check(r'"Jane \"Doe\"." <[email protected]>', | ||
' <[email protected]>') | ||
|
||
def test_check_parenthesis(self): | ||
addr = '[email protected]' | ||
self.assertTrue(utils._check_parenthesis(f'{addr} (Alice)')) | ||
self.assertFalse(utils._check_parenthesis(f'{addr} )Alice(')) | ||
self.assertFalse(utils._check_parenthesis(f'{addr} (Alice))')) | ||
self.assertFalse(utils._check_parenthesis(f'{addr} ((Alice)')) | ||
|
||
# Ignore real name between quotes | ||
self.assertTrue(utils._check_parenthesis(f'")Alice((" {addr}')) | ||
|
||
|
||
# Test the iterator/generators | ||
class TestIterators(TestEmailBase): | ||
|