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

Method test_pushCR_LF

Lib/test/test_email/test_email.py:3812–3840  ·  view source on GitHub ↗

FeedParser BufferedSubFile.push() assumed it received complete line endings. A CR ending one push() followed by a LF starting the next push() added an empty line.

(self)

Source from the content-addressed store, hash-verified

3810""")
3811
3812 def test_pushCR_LF(self):
3813 '''FeedParser BufferedSubFile.push() assumed it received complete
3814 line endings. A CR ending one push() followed by a LF starting
3815 the next push() added an empty line.
3816 '''
3817 imt = [
3818 ("a\r \n", 2),
3819 ("b", 0),
3820 ("c\n", 1),
3821 ("", 0),
3822 ("d\r\n", 1),
3823 ("e\r", 0),
3824 ("\nf", 1),
3825 ("\r\n", 1),
3826 ]
3827 from email.feedparser import BufferedSubFile, NeedMoreData
3828 bsf = BufferedSubFile()
3829 om = []
3830 nt = 0
3831 for il, n in imt:
3832 bsf.push(il)
3833 nt += n
3834 n1 = 0
3835 for ol in iter(bsf.readline, NeedMoreData):
3836 om.append(ol)
3837 n1 += 1
3838 self.assertEqual(n, n1)
3839 self.assertEqual(len(om), nt)
3840 self.assertEqual(''.join([il for il, n in imt]), ''.join(om))
3841
3842 def test_push_random(self):
3843 from email.feedparser import BufferedSubFile, NeedMoreData

Callers

nothing calls this directly

Calls 5

pushMethod · 0.95
BufferedSubFileClass · 0.90
appendMethod · 0.45
assertEqualMethod · 0.45
joinMethod · 0.45

Tested by

no test coverage detected