ImportModulesTestCase: use iterator, not list
authorZac Medico <zmedico@gentoo.org>
Mon, 31 Jan 2011 22:28:12 +0000 (14:28 -0800)
committerZac Medico <zmedico@gentoo.org>
Wed, 2 Feb 2011 23:25:21 +0000 (15:25 -0800)
pym/portage/tests/lint/test_import_modules.py

index 87bb4bf0785f87d5e9b20302290d75532c147964..8d257c5a6af179d36fc878791936aef426e199d0 100644 (file)
@@ -13,7 +13,7 @@ class ImportModulesTestCase(TestCase):
                expected_failures = frozenset((
                ))
 
-               for mod in self._list_modules(PORTAGE_PYM_PATH):
+               for mod in self._iter_modules(PORTAGE_PYM_PATH):
                        try:
                                __import__(mod)
                        except ImportError as e:
@@ -21,8 +21,7 @@ class ImportModulesTestCase(TestCase):
                                        self.assertTrue(False, "failed to import '%s': %s" % (mod, e))
                                del e
 
-       def _list_modules(self, base_dir):
-               all_modules = []
+       def _iter_modules(self, base_dir):
                for parent, dirs, files in os.walk(base_dir):
                        parent = _unicode_decode(parent,
                                encoding=_encodings['fs'], errors='strict')
@@ -38,6 +37,4 @@ class ImportModulesTestCase(TestCase):
                                        x = parent_mod
                                else:
                                        x = parent_mod + "." + x
-                               all_modules.append(x)
-
-               return all_modules
+                               yield x