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
328cf3cb
Commit
328cf3cb
authored
Nov 16, 2013
by
Serhiy Storchaka
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Issue #19590: Use specific asserts in email tests.
parent
9c10d6b8
Changes
4
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
92 additions
and
107 deletions
+92
-107
Lib/test/test_email/test_defect_handling.py
Lib/test/test_email/test_defect_handling.py
+13
-13
Lib/test/test_email/test_email.py
Lib/test/test_email/test_email.py
+75
-90
Lib/test/test_email/test_parser.py
Lib/test/test_email/test_parser.py
+2
-2
Lib/test/test_email/test_utils.py
Lib/test/test_email/test_utils.py
+2
-2
No files found.
Lib/test/test_email/test_defect_handling.py
View file @
328cf3cb
...
...
@@ -59,8 +59,8 @@ class TestDefectsBase:
inner
=
msg
.
get_payload
(
0
)
self
.
assertTrue
(
hasattr
(
inner
,
'defects'
))
self
.
assertEqual
(
len
(
self
.
get_defects
(
inner
)),
1
)
self
.
assert
True
(
isi
nstance
(
self
.
get_defects
(
inner
)[
0
],
errors
.
StartBoundaryNotFoundDefect
)
)
self
.
assert
IsI
nstance
(
self
.
get_defects
(
inner
)[
0
],
errors
.
StartBoundaryNotFoundDefect
)
def
test_multipart_no_boundary
(
self
):
source
=
textwrap
.
dedent
(
"""
\
...
...
@@ -84,12 +84,12 @@ class TestDefectsBase:
with
self
.
_raise_point
(
errors
.
NoBoundaryInMultipartDefect
):
msg
=
self
.
_str_msg
(
source
)
if
self
.
raise_expected
:
return
self
.
assert
True
(
isinstance
(
msg
.
get_payload
(),
str
)
)
self
.
assert
IsInstance
(
msg
.
get_payload
(),
str
)
self
.
assertEqual
(
len
(
self
.
get_defects
(
msg
)),
2
)
self
.
assert
True
(
isi
nstance
(
self
.
get_defects
(
msg
)[
0
],
errors
.
NoBoundaryInMultipartDefect
)
)
self
.
assert
True
(
isi
nstance
(
self
.
get_defects
(
msg
)[
1
],
errors
.
MultipartInvariantViolationDefect
)
)
self
.
assert
IsI
nstance
(
self
.
get_defects
(
msg
)[
0
],
errors
.
NoBoundaryInMultipartDefect
)
self
.
assert
IsI
nstance
(
self
.
get_defects
(
msg
)[
1
],
errors
.
MultipartInvariantViolationDefect
)
multipart_msg
=
textwrap
.
dedent
(
"""
\
Date: Wed, 14 Nov 2007 12:56:23 GMT
...
...
@@ -153,10 +153,10 @@ class TestDefectsBase:
if
self
.
raise_expected
:
return
self
.
assertTrue
(
hasattr
(
msg
,
'defects'
))
self
.
assertEqual
(
len
(
self
.
get_defects
(
msg
)),
2
)
self
.
assert
True
(
isi
nstance
(
self
.
get_defects
(
msg
)[
0
],
errors
.
NoBoundaryInMultipartDefect
)
)
self
.
assert
True
(
isi
nstance
(
self
.
get_defects
(
msg
)[
1
],
errors
.
MultipartInvariantViolationDefect
)
)
self
.
assert
IsI
nstance
(
self
.
get_defects
(
msg
)[
0
],
errors
.
NoBoundaryInMultipartDefect
)
self
.
assert
IsI
nstance
(
self
.
get_defects
(
msg
)[
1
],
errors
.
MultipartInvariantViolationDefect
)
def
test_missing_start_boundary
(
self
):
source
=
textwrap
.
dedent
(
"""
\
...
...
@@ -193,8 +193,8 @@ class TestDefectsBase:
if
self
.
raise_expected
:
return
bad
=
outer
.
get_payload
(
1
).
get_payload
(
0
)
self
.
assertEqual
(
len
(
self
.
get_defects
(
bad
)),
1
)
self
.
assert
True
(
isi
nstance
(
self
.
get_defects
(
bad
)[
0
],
errors
.
StartBoundaryNotFoundDefect
)
)
self
.
assert
IsI
nstance
(
self
.
get_defects
(
bad
)[
0
],
errors
.
StartBoundaryNotFoundDefect
)
def
test_first_line_is_continuation_header
(
self
):
with
self
.
_raise_point
(
errors
.
FirstHeaderLineIsContinuationDefect
):
...
...
Lib/test/test_email/test_email.py
View file @
328cf3cb
This diff is collapsed.
Click to expand it.
Lib/test/test_email/test_parser.py
View file @
328cf3cb
...
...
@@ -18,7 +18,7 @@ class TestCustomMessage(TestEmailBase):
msg
=
email
.
message_from_string
(
"Subject: bogus
\
n
\
n
msg
\
n
"
,
self
.
MyMessage
,
policy
=
self
.
MyPolicy
)
self
.
assert
True
(
isinstance
(
msg
,
self
.
MyMessage
)
)
self
.
assert
IsInstance
(
msg
,
self
.
MyMessage
)
self
.
assertIs
(
msg
.
check_policy
,
self
.
MyPolicy
)
def
test_custom_message_gets_policy_if_possible_from_file
(
self
):
...
...
@@ -26,7 +26,7 @@ class TestCustomMessage(TestEmailBase):
msg
=
email
.
message_from_file
(
source_file
,
self
.
MyMessage
,
policy
=
self
.
MyPolicy
)
self
.
assert
True
(
isinstance
(
msg
,
self
.
MyMessage
)
)
self
.
assert
IsInstance
(
msg
,
self
.
MyMessage
)
self
.
assertIs
(
msg
.
check_policy
,
self
.
MyPolicy
)
# XXX add tests for other functions that take Message arg.
...
...
Lib/test/test_email/test_utils.py
View file @
328cf3cb
...
...
@@ -54,12 +54,12 @@ class LocaltimeTests(unittest.TestCase):
def
test_localtime_is_tz_aware_daylight_true
(
self
):
test
.
support
.
patch
(
self
,
time
,
'daylight'
,
True
)
t
=
utils
.
localtime
()
self
.
assertIsNot
(
t
.
tzinfo
,
None
)
self
.
assertIsNot
None
(
t
.
tzinfo
)
def
test_localtime_is_tz_aware_daylight_false
(
self
):
test
.
support
.
patch
(
self
,
time
,
'daylight'
,
False
)
t
=
utils
.
localtime
()
self
.
assertIsNot
(
t
.
tzinfo
,
None
)
self
.
assertIsNot
None
(
t
.
tzinfo
)
def
test_localtime_daylight_true_dst_false
(
self
):
test
.
support
.
patch
(
self
,
time
,
'daylight'
,
True
)
...
...
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