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

Method test_encode

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

Source from the content-addressed store, hash-verified

4926 self.assertRaises(ValueError, self._test_encode, '', '', maxlinelen=3)
4927
4928 def test_encode(self):
4929 eq = self.assertEqual
4930 eq(quoprimime.body_encode(''), '')
4931 eq(quoprimime.body_encode('hello'), 'hello')
4932 # Test the binary flag
4933 eq(quoprimime.body_encode('hello\r\nworld'), 'hello\nworld')
4934 # Test the maxlinelen arg
4935 eq(quoprimime.body_encode('xxxx ' * 20, maxlinelen=40), """\
4936xxxx xxxx xxxx xxxx xxxx xxxx xxxx xxxx=
4937 xxxx xxxx xxxx xxxx xxxx xxxx xxxx xxx=
4938x xxxx xxxx xxxx xxxx=20""")
4939 # Test the eol argument
4940 eq(quoprimime.body_encode('xxxx ' * 20, maxlinelen=40, eol='\r\n'),
4941 """\
4942xxxx xxxx xxxx xxxx xxxx xxxx xxxx xxxx=\r
4943 xxxx xxxx xxxx xxxx xxxx xxxx xxxx xxx=\r
4944x xxxx xxxx xxxx xxxx=20""")
4945 eq(quoprimime.body_encode("""\
4946one line
4947
4948two line"""), """\
4949one line
4950
4951two line""")
4952
4953
4954

Callers

nothing calls this directly

Calls 2

eqFunction · 0.85
body_encodeMethod · 0.80

Tested by

no test coverage detected