summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorBarry Warsaw <barry@python.org>2001-10-04 18:18:37 (GMT)
committerBarry Warsaw <barry@python.org>2001-10-04 18:18:37 (GMT)
commitd1de6eacf22caf95aba6d76058267c8f5b6543b8 (patch)
treec1ae3ef71d046f521f3e07d8e67f9d3d8b4c698b
parentc4496f886bbf6c8c2ce3454c4f92c5c2b66770bd (diff)
downloadcpython-d1de6eacf22caf95aba6d76058267c8f5b6543b8.zip
cpython-d1de6eacf22caf95aba6d76058267c8f5b6543b8.tar.gz
cpython-d1de6eacf22caf95aba6d76058267c8f5b6543b8.tar.bz2
TestIterators: Tim Peters suggests a more succinct spelling of
"listify an iterator".
-rw-r--r--Lib/test/test_email.py16
1 files changed, 4 insertions, 12 deletions
diff --git a/Lib/test/test_email.py b/Lib/test/test_email.py
index c349974..0a6b808 100644
--- a/Lib/test/test_email.py
+++ b/Lib/test/test_email.py
@@ -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