[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]
[tor-commits] [stem/master] Condensing no-op iterations over DescriptorReaders
commit 5d61c479081b73eb241bf4a6c541e15ddb7ea713
Author: Damian Johnson <atagar@xxxxxxxxxxxxxx>
Date: Mon Mar 12 08:55:46 2012 -0700
Condensing no-op iterations over DescriptorReaders
At multiple points in the tests we were iterating over all of a
DescriptorReaders' items without doing anything. There's no need to do the
iteration via a loop - coverting it into a list does the same thing.
---
test/integ/descriptor/reader.py | 20 ++++----------------
1 files changed, 4 insertions(+), 16 deletions(-)
diff --git a/test/integ/descriptor/reader.py b/test/integ/descriptor/reader.py
index ded3d2d..cb3454a 100644
--- a/test/integ/descriptor/reader.py
+++ b/test/integ/descriptor/reader.py
@@ -213,10 +213,7 @@ class TestDescriptorReader(unittest.TestCase):
expected_results[path] = last_modified
reader = stem.descriptor.reader.DescriptorReader([DESCRIPTOR_TEST_DATA])
-
- with reader:
- for descriptor in reader:
- pass
+ with reader: list(reader) # iterates over all of the descriptors
self.assertEquals(expected_results, reader.get_processed_files())
@@ -260,10 +257,7 @@ class TestDescriptorReader(unittest.TestCase):
skip_listener = SkipListener()
reader = stem.descriptor.reader.DescriptorReader([test_path])
reader.register_skip_listener(skip_listener.listener)
-
- with reader:
- for descriptor in reader:
- pass
+ with reader: list(reader) # iterates over all of the descriptors
self.assertTrue(len(skip_listener.results) == 1)
@@ -291,10 +285,7 @@ class TestDescriptorReader(unittest.TestCase):
skip_listener = SkipListener()
reader = stem.descriptor.reader.DescriptorReader([test_path])
reader.register_skip_listener(skip_listener.listener)
-
- with reader:
- for descriptor in reader:
- pass
+ with reader: list(reader) # iterates over all of the descriptors
self.assertTrue(len(skip_listener.results) == 1)
@@ -316,10 +307,7 @@ class TestDescriptorReader(unittest.TestCase):
skip_listener = SkipListener()
reader = stem.descriptor.reader.DescriptorReader([test_path])
reader.register_skip_listener(skip_listener.listener)
-
- with reader:
- for descriptor in reader:
- pass
+ with reader: list(reader) # iterates over all of the descriptors
self.assertTrue(len(skip_listener.results) == 1)
_______________________________________________
tor-commits mailing list
tor-commits@xxxxxxxxxxxxxxxxxxxx
https://lists.torproject.org/cgi-bin/mailman/listinfo/tor-commits