mirror of
https://github.com/python/cpython.git
synced 2025-08-03 16:39:00 +00:00
TestIterators: Tim Peters suggests a more succinct spelling of
"listify an iterator".
This commit is contained in:
parent
c4496f886b
commit
d1de6eacf2
1 changed files with 4 additions and 12 deletions
|
@ -793,17 +793,13 @@ class TestIterators(TestEmailBase):
|
|||
# First a simple non-multipart message
|
||||
msg = self._msgobj('msg_01.txt')
|
||||
it = Iterators.body_line_iterator(msg)
|
||||
lines = []
|
||||
for line in it:
|
||||
lines.append(line)
|
||||
lines = list(it)
|
||||
eq(len(lines), 6)
|
||||
eq(EMPTYSTRING.join(lines), msg.get_payload())
|
||||
# Now a more complicated multipart
|
||||
msg = self._msgobj('msg_02.txt')
|
||||
it = Iterators.body_line_iterator(msg)
|
||||
lines = []
|
||||
for line in it:
|
||||
lines.append(line)
|
||||
lines = list(it)
|
||||
eq(len(lines), 43)
|
||||
eq(EMPTYSTRING.join(lines), openfile('msg_19.txt').read())
|
||||
|
||||
|
@ -811,12 +807,8 @@ class TestIterators(TestEmailBase):
|
|||
eq = self.assertEqual
|
||||
msg = self._msgobj('msg_04.txt')
|
||||
it = Iterators.typed_subpart_iterator(msg, 'text')
|
||||
lines = []
|
||||
subparts = 0
|
||||
for subpart in it:
|
||||
subparts += 1
|
||||
lines.append(subpart.get_payload())
|
||||
eq(subparts, 2)
|
||||
lines = [subpart.get_payload() for subpart in it]
|
||||
eq(len(lines), 2)
|
||||
eq(EMPTYSTRING.join(lines), """\
|
||||
a simple kind of mirror
|
||||
to reflect upon our own
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue