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
dc8087b2
Commit
dc8087b2
authored
Oct 10, 2002
by
Barry Warsaw
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
New tests to verify that charsets are case insensitive, and that by
default get_body_encoding() cannot be SHORTEST.
parent
ee07cb1d
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
34 additions
and
0 deletions
+34
-0
Lib/email/test/test_email.py
Lib/email/test/test_email.py
+34
-0
No files found.
Lib/email/test/test_email.py
View file @
dc8087b2
...
...
@@ -1689,6 +1689,40 @@ class TestMiscellaneous(unittest.TestCase):
filename
=
'foo
\
\
wacky"name'
)
eq
(
msg
.
get_filename
(),
'foo
\
\
wacky"name'
)
def
test_get_body_encoding_with_bogus_charset
(
self
):
charset
=
Charset
(
'not a charset'
)
self
.
assertEqual
(
charset
.
get_body_encoding
(),
'base64'
)
def
test_get_body_encoding_with_uppercase_charset
(
self
):
eq
=
self
.
assertEqual
msg
=
Message
()
msg
[
'Content-Type'
]
=
'text/plain; charset=UTF-8'
eq
(
msg
[
'content-type'
],
'text/plain; charset=UTF-8'
)
charsets
=
msg
.
get_charsets
()
eq
(
len
(
charsets
),
1
)
eq
(
charsets
[
0
],
'utf-8'
)
charset
=
Charset
(
charsets
[
0
])
eq
(
charset
.
get_body_encoding
(),
'base64'
)
msg
.
set_payload
(
'hello world'
,
charset
=
charset
)
eq
(
msg
.
get_payload
(),
'hello world'
)
eq
(
msg
[
'content-transfer-encoding'
],
'base64'
)
# Try another one
msg
=
Message
()
msg
[
'Content-Type'
]
=
'text/plain; charset="US-ASCII"'
charsets
=
msg
.
get_charsets
()
eq
(
len
(
charsets
),
1
)
eq
(
charsets
[
0
],
'us-ascii'
)
charset
=
Charset
(
charsets
[
0
])
eq
(
charset
.
get_body_encoding
(),
Encoders
.
encode_7or8bit
)
msg
.
set_payload
(
'hello world'
,
charset
=
charset
)
eq
(
msg
.
get_payload
(),
'hello world'
)
eq
(
msg
[
'content-transfer-encoding'
],
'7bit'
)
def
test_charsets_case_insensitive
(
self
):
lc
=
Charset
(
'us-ascii'
)
uc
=
Charset
(
'US-ASCII'
)
self
.
assertEqual
(
lc
.
get_body_encoding
(),
uc
.
get_body_encoding
())
# Test the iterator/generators
...
...
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