From: Zac Medico Date: Mon, 31 Jan 2011 22:28:12 +0000 (-0800) Subject: ImportModulesTestCase: use iterator, not list X-Git-Tag: v2.2.0_alpha20~48 X-Git-Url: http://git.tremily.us/?a=commitdiff_plain;h=72aa86e97367849e7dd867d0320bbf0b91c836a6;p=portage.git ImportModulesTestCase: use iterator, not list --- diff --git a/pym/portage/tests/lint/test_import_modules.py b/pym/portage/tests/lint/test_import_modules.py index 87bb4bf07..8d257c5a6 100644 --- a/pym/portage/tests/lint/test_import_modules.py +++ b/pym/portage/tests/lint/test_import_modules.py @@ -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