diff options
author | R David Murray <rdmurray@bitdance.com> | 2011-03-24 16:28:39 (GMT) |
---|---|---|
committer | R David Murray <rdmurray@bitdance.com> | 2011-03-24 16:28:39 (GMT) |
commit | 73bd0448b9ab5bfab7ba4b80cc384b2ce828da06 (patch) | |
tree | 20119e64d93b34f4bed16687f458ebe3f367eb1a /Lib/test/test_email | |
parent | f09e652a0e2d71696e0163565bcb4cc6020e4775 (diff) | |
parent | c7d28be62f56a9089b1a96b2d46a7041822c5885 (diff) | |
download | cpython-73bd0448b9ab5bfab7ba4b80cc384b2ce828da06.zip cpython-73bd0448b9ab5bfab7ba4b80cc384b2ce828da06.tar.gz cpython-73bd0448b9ab5bfab7ba4b80cc384b2ce828da06.tar.bz2 |
Merge #11606: improved body_encode algorithm, no longer produces overlong lines
Diffstat (limited to 'Lib/test/test_email')
-rw-r--r-- | Lib/test/test_email/test_email.py | 19 |
1 files changed, 18 insertions, 1 deletions
diff --git a/Lib/test/test_email/test_email.py b/Lib/test/test_email/test_email.py index bc6a309..ec9421d 100644 --- a/Lib/test/test_email/test_email.py +++ b/Lib/test/test_email/test_email.py @@ -3502,6 +3502,14 @@ class TestQuopri(unittest.TestCase): def test_encode_one_line_one_space(self): self._test_encode(' \n', '=20\n') +# XXX: body_encode() expect strings, but uses ord(char) from these strings +# to index into a 256-entry list. For code points above 255, this will fail. +# Should there be a check for 8-bit only ord() values in body, or at least +# a comment about the expected input? + + def test_encode_two_lines_one_space(self): + self._test_encode(' \n \n', '=20\n=20\n') + def test_encode_one_word_trailing_spaces(self): self._test_encode('hello ', 'hello =20') @@ -3517,8 +3525,14 @@ class TestQuopri(unittest.TestCase): def test_encode_trailing_space_before_maxlinelen(self): self._test_encode('abcd \n1234', 'abcd =\n\n1234', maxlinelen=6) + def test_encode_trailing_space_at_maxlinelen(self): + self._test_encode('abcd \n1234', 'abcd=\n=20\n1234', maxlinelen=5) + def test_encode_trailing_space_beyond_maxlinelen(self): - self._test_encode('abcd \n1234', 'abc=\nd =\n\n1234', maxlinelen=4) + self._test_encode('abcd \n1234', 'abc=\nd=20\n1234', maxlinelen=4) + + def test_encode_whitespace_lines(self): + self._test_encode(' \n' * 5, '=20\n' * 5) def test_encode_quoted_equals(self): self._test_encode('a = b', 'a =3D b') @@ -3539,6 +3553,9 @@ class TestQuopri(unittest.TestCase): def test_encode_shortest_maxlinelen(self): self._test_encode('=' * 5, '=3D=\n' * 4 + '=3D', maxlinelen=4) + def test_encode_maxlinelen_too_small(self): + self.assertRaises(ValueError, self._test_encode, '', '', maxlinelen=3) + def test_encode(self): eq = self.assertEqual eq(quoprimime.body_encode(''), '') |