Commit d1de6eac authored by Barry Warsaw's avatar Barry Warsaw

TestIterators: Tim Peters suggests a more succinct spelling of

"listify an iterator".
parent c4496f88
...@@ -793,17 +793,13 @@ class TestIterators(TestEmailBase): ...@@ -793,17 +793,13 @@ class TestIterators(TestEmailBase):
# First a simple non-multipart message # First a simple non-multipart message
msg = self._msgobj('msg_01.txt') msg = self._msgobj('msg_01.txt')
it = Iterators.body_line_iterator(msg) it = Iterators.body_line_iterator(msg)
lines = [] lines = list(it)
for line in it:
lines.append(line)
eq(len(lines), 6) eq(len(lines), 6)
eq(EMPTYSTRING.join(lines), msg.get_payload()) eq(EMPTYSTRING.join(lines), msg.get_payload())
# Now a more complicated multipart # Now a more complicated multipart
msg = self._msgobj('msg_02.txt') msg = self._msgobj('msg_02.txt')
it = Iterators.body_line_iterator(msg) it = Iterators.body_line_iterator(msg)
lines = [] lines = list(it)
for line in it:
lines.append(line)
eq(len(lines), 43) eq(len(lines), 43)
eq(EMPTYSTRING.join(lines), openfile('msg_19.txt').read()) eq(EMPTYSTRING.join(lines), openfile('msg_19.txt').read())
...@@ -811,12 +807,8 @@ class TestIterators(TestEmailBase): ...@@ -811,12 +807,8 @@ class TestIterators(TestEmailBase):
eq = self.assertEqual eq = self.assertEqual
msg = self._msgobj('msg_04.txt') msg = self._msgobj('msg_04.txt')
it = Iterators.typed_subpart_iterator(msg, 'text') it = Iterators.typed_subpart_iterator(msg, 'text')
lines = [] lines = [subpart.get_payload() for subpart in it]
subparts = 0 eq(len(lines), 2)
for subpart in it:
subparts += 1
lines.append(subpart.get_payload())
eq(subparts, 2)
eq(EMPTYSTRING.join(lines), """\ eq(EMPTYSTRING.join(lines), """\
a simple kind of mirror a simple kind of mirror
to reflect upon our own to reflect upon our own
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment