Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
C
cpython
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Kirill Smelkov
cpython
Commits
d41595b9
Commit
d41595b9
authored
May 28, 2012
by
R David Murray
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Refactor test_email/test_defect_handling.
parent
3e0a1eb8
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
162 additions
and
179 deletions
+162
-179
Lib/test/test_email/test_defect_handling.py
Lib/test/test_email/test_defect_handling.py
+161
-178
Lib/test/test_email/test_email.py
Lib/test/test_email/test_email.py
+1
-1
No files found.
Lib/test/test_email/test_defect_handling.py
View file @
d41595b9
import
textwrap
import
textwrap
import
unittest
import
unittest
from
email._policybase
import
Compat32
import
contextlib
from
email
import
policy
from
email
import
errors
from
email
import
errors
from
test.test_email
import
TestEmailBase
from
test.test_email
import
TestEmailBase
class
Test
MessageDefectDetection
Base
:
class
Test
Defects
Base
:
dup_boundary_msg
=
textwrap
.
dedent
(
"""
\
policy
=
policy
.
default
raise_expected
=
False
@
contextlib
.
contextmanager
def
_raise_point
(
self
,
defect
):
yield
def
test_same_boundary_inner_outer
(
self
):
source
=
textwrap
.
dedent
(
"""
\
Subject: XX
Subject: XX
From: xx@xx.dk
From: xx@xx.dk
To: XX
To: XX
...
@@ -43,22 +52,18 @@ class TestMessageDefectDetectionBase:
...
@@ -43,22 +52,18 @@ class TestMessageDefectDetectionBase:
--MS_Mac_OE_3071477847_720252_MIME_Part--
--MS_Mac_OE_3071477847_720252_MIME_Part--
"""
)
"""
)
def
test_same_boundary_inner_outer
(
self
):
# XXX better would be to actually detect the duplicate.
# XXX better would be to actually detect the duplicate.
msg
=
self
.
_str_msg
(
self
.
dup_boundary_msg
)
with
self
.
_raise_point
(
errors
.
StartBoundaryNotFoundDefect
):
msg
=
self
.
_str_msg
(
source
)
if
self
.
raise_expected
:
return
inner
=
msg
.
get_payload
(
0
)
inner
=
msg
.
get_payload
(
0
)
self
.
assertTrue
(
hasattr
(
inner
,
'defects'
))
self
.
assertTrue
(
hasattr
(
inner
,
'defects'
))
self
.
assertEqual
(
len
(
self
.
get_defects
(
inner
)),
1
)
self
.
assertEqual
(
len
(
self
.
get_defects
(
inner
)),
1
)
self
.
assertTrue
(
isinstance
(
self
.
get_defects
(
inner
)[
0
],
self
.
assertTrue
(
isinstance
(
self
.
get_defects
(
inner
)[
0
],
errors
.
StartBoundaryNotFoundDefect
))
errors
.
StartBoundaryNotFoundDefect
))
def
test_same_boundary_inner_outer_raises_on_defect
(
self
):
def
test_multipart_no_boundary
(
self
):
with
self
.
assertRaises
(
errors
.
StartBoundaryNotFoundDefect
):
source
=
textwrap
.
dedent
(
"""
\
self
.
_str_msg
(
self
.
dup_boundary_msg
,
policy
=
self
.
policy
.
clone
(
raise_on_defect
=
True
))
no_boundary_msg
=
textwrap
.
dedent
(
"""
\
Date: Fri, 6 Apr 2001 09:23:06 -0800 (GMT-0800)
Date: Fri, 6 Apr 2001 09:23:06 -0800 (GMT-0800)
From: foobar
From: foobar
Subject: broken mail
Subject: broken mail
...
@@ -76,9 +81,9 @@ class TestMessageDefectDetectionBase:
...
@@ -76,9 +81,9 @@ class TestMessageDefectDetectionBase:
--JAB03225.986577786/zinfandel.lacita.com--
--JAB03225.986577786/zinfandel.lacita.com--
"""
)
"""
)
with
self
.
_raise_point
(
errors
.
NoBoundaryInMultipartDefect
):
def
test_multipart_no_boundary
(
self
):
msg
=
self
.
_str_msg
(
source
)
msg
=
self
.
_str_msg
(
self
.
no_boundary_msg
)
if
self
.
raise_expected
:
return
self
.
assertTrue
(
isinstance
(
msg
.
get_payload
(),
str
))
self
.
assertTrue
(
isinstance
(
msg
.
get_payload
(),
str
))
self
.
assertEqual
(
len
(
self
.
get_defects
(
msg
)),
2
)
self
.
assertEqual
(
len
(
self
.
get_defects
(
msg
)),
2
)
self
.
assertTrue
(
isinstance
(
self
.
get_defects
(
msg
)[
0
],
self
.
assertTrue
(
isinstance
(
self
.
get_defects
(
msg
)[
0
],
...
@@ -86,11 +91,6 @@ class TestMessageDefectDetectionBase:
...
@@ -86,11 +91,6 @@ class TestMessageDefectDetectionBase:
self
.
assertTrue
(
isinstance
(
self
.
get_defects
(
msg
)[
1
],
self
.
assertTrue
(
isinstance
(
self
.
get_defects
(
msg
)[
1
],
errors
.
MultipartInvariantViolationDefect
))
errors
.
MultipartInvariantViolationDefect
))
def
test_multipart_no_boundary_raise_on_defect
(
self
):
with
self
.
assertRaises
(
errors
.
NoBoundaryInMultipartDefect
):
self
.
_str_msg
(
self
.
no_boundary_msg
,
policy
=
self
.
policy
.
clone
(
raise_on_defect
=
True
))
multipart_msg
=
textwrap
.
dedent
(
"""
\
multipart_msg
=
textwrap
.
dedent
(
"""
\
Date: Wed, 14 Nov 2007 12:56:23 GMT
Date: Wed, 14 Nov 2007 12:56:23 GMT
From: foo@bar.invalid
From: foo@bar.invalid
...
@@ -115,31 +115,30 @@ class TestMessageDefectDetectionBase:
...
@@ -115,31 +115,30 @@ class TestMessageDefectDetectionBase:
"""
)
"""
)
def
test_multipart_invalid_cte
(
self
):
def
test_multipart_invalid_cte
(
self
):
with
self
.
_raise_point
(
errors
.
InvalidMultipartContentTransferEncodingDefect
):
msg
=
self
.
_str_msg
(
msg
=
self
.
_str_msg
(
self
.
multipart_msg
.
format
(
"
\
n
Content-Transfer-Encoding: base64"
))
self
.
multipart_msg
.
format
(
"
\
n
Content-Transfer-Encoding: base64"
))
if
self
.
raise_expected
:
return
self
.
assertEqual
(
len
(
self
.
get_defects
(
msg
)),
1
)
self
.
assertEqual
(
len
(
self
.
get_defects
(
msg
)),
1
)
self
.
assertIsInstance
(
self
.
get_defects
(
msg
)[
0
],
self
.
assertIsInstance
(
self
.
get_defects
(
msg
)[
0
],
errors
.
InvalidMultipartContentTransferEncodingDefect
)
errors
.
InvalidMultipartContentTransferEncodingDefect
)
def
test_multipart_invalid_cte_raise_on_defect
(
self
):
with
self
.
assertRaises
(
errors
.
InvalidMultipartContentTransferEncodingDefect
):
self
.
_str_msg
(
self
.
multipart_msg
.
format
(
"
\
n
Content-Transfer-Encoding: base64"
),
policy
=
self
.
policy
.
clone
(
raise_on_defect
=
True
))
def
test_multipart_no_cte_no_defect
(
self
):
def
test_multipart_no_cte_no_defect
(
self
):
if
self
.
raise_expected
:
return
msg
=
self
.
_str_msg
(
self
.
multipart_msg
.
format
(
''
))
msg
=
self
.
_str_msg
(
self
.
multipart_msg
.
format
(
''
))
self
.
assertEqual
(
len
(
self
.
get_defects
(
msg
)),
0
)
self
.
assertEqual
(
len
(
self
.
get_defects
(
msg
)),
0
)
def
test_multipart_valid_cte_no_defect
(
self
):
def
test_multipart_valid_cte_no_defect
(
self
):
if
self
.
raise_expected
:
return
for
cte
in
(
'7bit'
,
'8bit'
,
'BINary'
):
for
cte
in
(
'7bit'
,
'8bit'
,
'BINary'
):
msg
=
self
.
_str_msg
(
msg
=
self
.
_str_msg
(
self
.
multipart_msg
.
format
(
"
\
n
Content-Transfer-Encoding: "
+
cte
))
self
.
multipart_msg
.
format
(
"
\
n
Content-Transfer-Encoding: "
+
cte
))
self
.
assertEqual
(
len
(
self
.
get_defects
(
msg
)),
0
,
"cte="
+
cte
)
self
.
assertEqual
(
len
(
self
.
get_defects
(
msg
)),
0
,
"cte="
+
cte
)
lying_multipart_msg
=
textwrap
.
dedent
(
"""
\
def
test_lying_multipart
(
self
):
source
=
textwrap
.
dedent
(
"""
\
From: "Allison Dunlap" <xxx@example.com>
From: "Allison Dunlap" <xxx@example.com>
To: yyy@example.com
To: yyy@example.com
Subject: 64423
Subject: 64423
...
@@ -149,9 +148,9 @@ class TestMessageDefectDetectionBase:
...
@@ -149,9 +148,9 @@ class TestMessageDefectDetectionBase:
Blah blah blah
Blah blah blah
"""
)
"""
)
with
self
.
_raise_point
(
errors
.
NoBoundaryInMultipartDefect
):
def
test_lying_multipart
(
self
):
msg
=
self
.
_str_msg
(
source
)
msg
=
self
.
_str_msg
(
self
.
lying_multipart_msg
)
if
self
.
raise_expected
:
return
self
.
assertTrue
(
hasattr
(
msg
,
'defects'
))
self
.
assertTrue
(
hasattr
(
msg
,
'defects'
))
self
.
assertEqual
(
len
(
self
.
get_defects
(
msg
)),
2
)
self
.
assertEqual
(
len
(
self
.
get_defects
(
msg
)),
2
)
self
.
assertTrue
(
isinstance
(
self
.
get_defects
(
msg
)[
0
],
self
.
assertTrue
(
isinstance
(
self
.
get_defects
(
msg
)[
0
],
...
@@ -159,12 +158,8 @@ class TestMessageDefectDetectionBase:
...
@@ -159,12 +158,8 @@ class TestMessageDefectDetectionBase:
self
.
assertTrue
(
isinstance
(
self
.
get_defects
(
msg
)[
1
],
self
.
assertTrue
(
isinstance
(
self
.
get_defects
(
msg
)[
1
],
errors
.
MultipartInvariantViolationDefect
))
errors
.
MultipartInvariantViolationDefect
))
def
test_lying_multipart_raise_on_defect
(
self
):
def
test_missing_start_boundary
(
self
):
with
self
.
assertRaises
(
errors
.
NoBoundaryInMultipartDefect
):
source
=
textwrap
.
dedent
(
"""
\
self
.
_str_msg
(
self
.
lying_multipart_msg
,
policy
=
self
.
policy
.
clone
(
raise_on_defect
=
True
))
missing_start_boundary_msg
=
textwrap
.
dedent
(
"""
\
Content-Type: multipart/mixed; boundary="AAA"
Content-Type: multipart/mixed; boundary="AAA"
From: Mail Delivery Subsystem <xxx@example.com>
From: Mail Delivery Subsystem <xxx@example.com>
To: yyy@example.com
To: yyy@example.com
...
@@ -185,8 +180,6 @@ class TestMessageDefectDetectionBase:
...
@@ -185,8 +180,6 @@ class TestMessageDefectDetectionBase:
--AAA--
--AAA--
"""
)
"""
)
def
test_missing_start_boundary
(
self
):
# The message structure is:
# The message structure is:
#
#
# multipart/mixed
# multipart/mixed
...
@@ -195,19 +188,18 @@ class TestMessageDefectDetectionBase:
...
@@ -195,19 +188,18 @@ class TestMessageDefectDetectionBase:
# multipart/mixed [*]
# multipart/mixed [*]
#
#
# [*] This message is missing its start boundary
# [*] This message is missing its start boundary
outer
=
self
.
_str_msg
(
self
.
missing_start_boundary_msg
)
with
self
.
_raise_point
(
errors
.
StartBoundaryNotFoundDefect
):
outer
=
self
.
_str_msg
(
source
)
if
self
.
raise_expected
:
return
bad
=
outer
.
get_payload
(
1
).
get_payload
(
0
)
bad
=
outer
.
get_payload
(
1
).
get_payload
(
0
)
self
.
assertEqual
(
len
(
self
.
get_defects
(
bad
)),
1
)
self
.
assertEqual
(
len
(
self
.
get_defects
(
bad
)),
1
)
self
.
assertTrue
(
isinstance
(
self
.
get_defects
(
bad
)[
0
],
self
.
assertTrue
(
isinstance
(
self
.
get_defects
(
bad
)[
0
],
errors
.
StartBoundaryNotFoundDefect
))
errors
.
StartBoundaryNotFoundDefect
))
def
test_missing_start_boundary_raise_on_defect
(
self
):
with
self
.
assertRaises
(
errors
.
StartBoundaryNotFoundDefect
):
self
.
_str_msg
(
self
.
missing_start_boundary_msg
,
policy
=
self
.
policy
.
clone
(
raise_on_defect
=
True
))
def
test_first_line_is_continuation_header
(
self
):
def
test_first_line_is_continuation_header
(
self
):
with
self
.
_raise_point
(
errors
.
FirstHeaderLineIsContinuationDefect
):
msg
=
self
.
_str_msg
(
' Line 1
\
n
Subject: test
\
n
\
n
body'
)
msg
=
self
.
_str_msg
(
' Line 1
\
n
Subject: test
\
n
\
n
body'
)
if
self
.
raise_expected
:
return
self
.
assertEqual
(
msg
.
keys
(),
[
'Subject'
])
self
.
assertEqual
(
msg
.
keys
(),
[
'Subject'
])
self
.
assertEqual
(
msg
.
get_payload
(),
'body'
)
self
.
assertEqual
(
msg
.
get_payload
(),
'body'
)
self
.
assertEqual
(
len
(
self
.
get_defects
(
msg
)),
1
)
self
.
assertEqual
(
len
(
self
.
get_defects
(
msg
)),
1
)
...
@@ -215,28 +207,21 @@ class TestMessageDefectDetectionBase:
...
@@ -215,28 +207,21 @@ class TestMessageDefectDetectionBase:
[
errors
.
FirstHeaderLineIsContinuationDefect
])
[
errors
.
FirstHeaderLineIsContinuationDefect
])
self
.
assertEqual
(
self
.
get_defects
(
msg
)[
0
].
line
,
' Line 1
\
n
'
)
self
.
assertEqual
(
self
.
get_defects
(
msg
)[
0
].
line
,
' Line 1
\
n
'
)
def
test_first_line_is_continuation_header_raise_on_defect
(
self
):
with
self
.
assertRaises
(
errors
.
FirstHeaderLineIsContinuationDefect
):
self
.
_str_msg
(
' Line 1
\
n
Subject: test
\
n
\
n
body
\
n
'
,
policy
=
self
.
policy
.
clone
(
raise_on_defect
=
True
))
def
test_missing_header_body_separator
(
self
):
def
test_missing_header_body_separator
(
self
):
# Our heuristic if we see a line that doesn't look like a header (no
# Our heuristic if we see a line that doesn't look like a header (no
# leading whitespace but no ':') is to assume that the blank line that
# leading whitespace but no ':') is to assume that the blank line that
# separates the header from the body is missing, and to stop parsing
# separates the header from the body is missing, and to stop parsing
# headers and start parsing the body.
# headers and start parsing the body.
with
self
.
_raise_point
(
errors
.
MissingHeaderBodySeparatorDefect
):
msg
=
self
.
_str_msg
(
'Subject: test
\
n
not a header
\
n
To: abc
\
n
\
n
b
\
n
'
)
msg
=
self
.
_str_msg
(
'Subject: test
\
n
not a header
\
n
To: abc
\
n
\
n
b
\
n
'
)
if
self
.
raise_expected
:
return
self
.
assertEqual
(
msg
.
keys
(),
[
'Subject'
])
self
.
assertEqual
(
msg
.
keys
(),
[
'Subject'
])
self
.
assertEqual
(
msg
.
get_payload
(),
'not a header
\
n
To: abc
\
n
\
n
b
\
n
'
)
self
.
assertEqual
(
msg
.
get_payload
(),
'not a header
\
n
To: abc
\
n
\
n
b
\
n
'
)
self
.
assertDefectsEqual
(
self
.
get_defects
(
msg
),
self
.
assertDefectsEqual
(
self
.
get_defects
(
msg
),
[
errors
.
MissingHeaderBodySeparatorDefect
])
[
errors
.
MissingHeaderBodySeparatorDefect
])
def
test_missing_header_body_separator_raise_on_defect
(
self
):
def
test_bad_padding_in_base64_payload
(
self
):
with
self
.
assertRaises
(
errors
.
MissingHeaderBodySeparatorDefect
):
source
=
textwrap
.
dedent
(
"""
\
self
.
_str_msg
(
'Subject: test
\
n
not a header
\
n
To: abc
\
n
\
n
b
\
n
'
,
policy
=
self
.
policy
.
clone
(
raise_on_defect
=
True
))
badly_padded_base64_payload
=
textwrap
.
dedent
(
"""
\
Subject: test
Subject: test
MIME-Version: 1.0
MIME-Version: 1.0
Content-Type: text/plain; charset="utf-8"
Content-Type: text/plain; charset="utf-8"
...
@@ -244,20 +229,16 @@ class TestMessageDefectDetectionBase:
...
@@ -244,20 +229,16 @@ class TestMessageDefectDetectionBase:
dmk
dmk
"""
)
"""
)
msg
=
self
.
_str_msg
(
source
)
def
test_bad_padding_in_base64_payload
(
self
):
with
self
.
_raise_point
(
errors
.
InvalidBase64PaddingDefect
):
msg
=
self
.
_str_msg
(
self
.
badly_padded_base64_payload
)
payload
=
msg
.
get_payload
(
decode
=
True
)
self
.
assertEqual
(
msg
.
get_payload
(
decode
=
True
),
b'vi'
)
if
self
.
raise_expected
:
return
self
.
assertEqual
(
payload
,
b'vi'
)
self
.
assertDefectsEqual
(
self
.
get_defects
(
msg
),
self
.
assertDefectsEqual
(
self
.
get_defects
(
msg
),
[
errors
.
InvalidBase64PaddingDefect
])
[
errors
.
InvalidBase64PaddingDefect
])
def
test_bad_padding_in_base64_payload_raise_on_defect
(
self
):
def
test_invalid_chars_in_base64_payload
(
self
):
msg
=
self
.
_str_msg
(
self
.
badly_padded_base64_payload
,
source
=
textwrap
.
dedent
(
"""
\
policy
=
self
.
policy
.
clone
(
raise_on_defect
=
True
))
with
self
.
assertRaises
(
errors
.
InvalidBase64PaddingDefect
):
msg
.
get_payload
(
decode
=
True
)
invalid_chars_in_base64_payload
=
textwrap
.
dedent
(
"""
\
Subject: test
Subject: test
MIME-Version: 1.0
MIME-Version: 1.0
Content-Type: text/plain; charset="utf-8"
Content-Type: text/plain; charset="utf-8"
...
@@ -265,20 +246,16 @@ class TestMessageDefectDetectionBase:
...
@@ -265,20 +246,16 @@ class TestMessageDefectDetectionBase:
dm
\
x01
k===
dm
\
x01
k===
"""
)
"""
)
msg
=
self
.
_str_msg
(
source
)
def
test_invalid_chars_in_base64_payload
(
self
):
with
self
.
_raise_point
(
errors
.
InvalidBase64CharactersDefect
):
msg
=
self
.
_str_msg
(
self
.
invalid_chars_in_base64_payload
)
payload
=
msg
.
get_payload
(
decode
=
True
)
self
.
assertEqual
(
msg
.
get_payload
(
decode
=
True
),
b'vi'
)
if
self
.
raise_expected
:
return
self
.
assertEqual
(
payload
,
b'vi'
)
self
.
assertDefectsEqual
(
self
.
get_defects
(
msg
),
self
.
assertDefectsEqual
(
self
.
get_defects
(
msg
),
[
errors
.
InvalidBase64CharactersDefect
])
[
errors
.
InvalidBase64CharactersDefect
])
def
test_invalid_chars_in_base64_payload_raise_on_defect
(
self
):
def
test_missing_ending_boundary
(
self
):
msg
=
self
.
_str_msg
(
self
.
invalid_chars_in_base64_payload
,
source
=
textwrap
.
dedent
(
"""
\
policy
=
self
.
policy
.
clone
(
raise_on_defect
=
True
))
with
self
.
assertRaises
(
errors
.
InvalidBase64CharactersDefect
):
msg
.
get_payload
(
decode
=
True
)
missing_ending_boundary
=
textwrap
.
dedent
(
"""
\
To: 1@harrydomain4.com
To: 1@harrydomain4.com
Subject: Fwd: 1
Subject: Fwd: 1
MIME-Version: 1.0
MIME-Version: 1.0
...
@@ -298,30 +275,24 @@ class TestMessageDefectDetectionBase:
...
@@ -298,30 +275,24 @@ class TestMessageDefectDetectionBase:
Alternative 2
Alternative 2
"""
)
"""
)
with
self
.
_raise_point
(
errors
.
CloseBoundaryNotFoundDefect
):
def
test_missing_ending_boundary
(
self
):
msg
=
self
.
_str_msg
(
source
)
msg
=
self
.
_str_msg
(
self
.
missing_ending_boundary
)
if
self
.
raise_expected
:
return
self
.
assertEqual
(
len
(
msg
.
get_payload
()),
2
)
self
.
assertEqual
(
len
(
msg
.
get_payload
()),
2
)
self
.
assertEqual
(
msg
.
get_payload
(
1
).
get_payload
(),
'Alternative 2
\
n
'
)
self
.
assertEqual
(
msg
.
get_payload
(
1
).
get_payload
(),
'Alternative 2
\
n
'
)
self
.
assertDefectsEqual
(
self
.
get_defects
(
msg
),
self
.
assertDefectsEqual
(
self
.
get_defects
(
msg
),
[
errors
.
CloseBoundaryNotFoundDefect
])
[
errors
.
CloseBoundaryNotFoundDefect
])
def
test_missing_ending_boundary_raise_on_defect
(
self
):
with
self
.
assertRaises
(
errors
.
CloseBoundaryNotFoundDefect
):
self
.
_str_msg
(
self
.
missing_ending_boundary
,
policy
=
self
.
policy
.
clone
(
raise_on_defect
=
True
))
class
TestDefectDetection
(
TestDefectsBase
,
TestEmailBase
):
class
TestMessageDefectDetection
(
TestMessageDefectDetectionBase
,
TestEmailBase
):
def
get_defects
(
self
,
obj
):
def
get_defects
(
self
,
obj
):
return
obj
.
defects
return
obj
.
defects
class
TestMessageDefectDetectionCapture
(
TestMessageDefectDetectionBase
,
class
TestDefectCapture
(
TestDefectsBase
,
TestEmailBase
):
TestEmailBase
):
class
CapturePolicy
(
Compat32
):
class
CapturePolicy
(
policy
.
EmailPolicy
):
captured
=
None
captured
=
None
def
register_defect
(
self
,
obj
,
defect
):
def
register_defect
(
self
,
obj
,
defect
):
self
.
captured
.
append
(
defect
)
self
.
captured
.
append
(
defect
)
...
@@ -333,5 +304,17 @@ class TestMessageDefectDetectionCapture(TestMessageDefectDetectionBase,
...
@@ -333,5 +304,17 @@ class TestMessageDefectDetectionCapture(TestMessageDefectDetectionBase,
return
self
.
policy
.
captured
return
self
.
policy
.
captured
class
TestDefectRaising
(
TestDefectsBase
,
TestEmailBase
):
policy
=
TestDefectsBase
.
policy
policy
=
policy
.
clone
(
raise_on_defect
=
True
)
raise_expected
=
True
@
contextlib
.
contextmanager
def
_raise_point
(
self
,
defect
):
with
self
.
assertRaises
(
defect
):
yield
if
__name__
==
'__main__'
:
if
__name__
==
'__main__'
:
unittest
.
main
()
unittest
.
main
()
Lib/test/test_email/test_email.py
View file @
d41595b9
...
@@ -1973,7 +1973,7 @@ counter to RFC 2822, there's no separating newline here
...
@@ -1973,7 +1973,7 @@ counter to RFC 2822, there's no separating newline here
[
errors
.
FirstHeaderLineIsContinuationDefect
])
[
errors
.
FirstHeaderLineIsContinuationDefect
])
eq
(
msg
.
defects
[
0
].
line
,
' Line 1
\
n
'
)
eq
(
msg
.
defects
[
0
].
line
,
' Line 1
\
n
'
)
# test_
parser.TestMessageDefectDetectionBase
# test_
defect_handling
def
test_missing_header_body_separator
(
self
):
def
test_missing_header_body_separator
(
self
):
# Our heuristic if we see a line that doesn't look like a header (no
# Our heuristic if we see a line that doesn't look like a header (no
# leading whitespace but no ':') is to assume that the blank line that
# leading whitespace but no ':') is to assume that the blank line that
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment