MCPcopy Index your code
hub / github.com/python/cpython / test_getset_charset

Method test_getset_charset

Lib/test/test_email/test_email.py:65–89  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

63 eq(msg.get_all('xx', 'n/a'), 'n/a')
64
65 def test_getset_charset(self):
66 eq = self.assertEqual
67 msg = Message()
68 eq(msg.get_charset(), None)
69 charset = Charset('iso-8859-1')
70 msg.set_charset(charset)
71 eq(msg['mime-version'], '1.0')
72 eq(msg.get_content_type(), 'text/plain')
73 eq(msg['content-type'], 'text/plain; charset="iso-8859-1"')
74 eq(msg.get_param('charset'), 'iso-8859-1')
75 eq(msg['content-transfer-encoding'], 'quoted-printable')
76 eq(msg.get_charset().input_charset, 'iso-8859-1')
77 # Remove the charset
78 msg.set_charset(None)
79 eq(msg.get_charset(), None)
80 eq(msg['content-type'], 'text/plain')
81 # Try adding a charset when there's already MIME headers present
82 msg = Message()
83 msg['MIME-Version'] = '2.0'
84 msg['Content-Type'] = 'text/x-weird'
85 msg['Content-Transfer-Encoding'] = 'quinted-puntable'
86 msg.set_charset(charset)
87 eq(msg['mime-version'], '2.0')
88 eq(msg['content-type'], 'text/x-weird; charset="iso-8859-1"')
89 eq(msg['content-transfer-encoding'], 'quinted-puntable')
90
91 def test_set_charset_from_string(self):
92 eq = self.assertEqual

Callers

nothing calls this directly

Calls 7

get_charsetMethod · 0.95
set_charsetMethod · 0.95
get_content_typeMethod · 0.95
get_paramMethod · 0.95
MessageClass · 0.90
CharsetClass · 0.90
eqFunction · 0.85

Tested by

no test coverage detected