diff options
author | Zac Medico <zmedico@gentoo.org> | 2011-01-28 23:54:50 -0800 |
---|---|---|
committer | Zac Medico <zmedico@gentoo.org> | 2011-01-28 23:54:50 -0800 |
commit | 149482208c430cbd9d730c35256430ea6cf58c3d (patch) | |
tree | 4351f626ea44a5fd262a97c3c7a569d458334bb1 /pym/portage/tests/lint | |
parent | a3ddca88b876d359ef92d9544999d1bf580061fb (diff) | |
download | portage-149482208c430cbd9d730c35256430ea6cf58c3d.tar.gz portage-149482208c430cbd9d730c35256430ea6cf58c3d.tar.bz2 portage-149482208c430cbd9d730c35256430ea6cf58c3d.zip |
Test import of all modules.
Diffstat (limited to 'pym/portage/tests/lint')
-rw-r--r-- | pym/portage/tests/lint/test_import_modules.py | 35 |
1 files changed, 35 insertions, 0 deletions
diff --git a/pym/portage/tests/lint/test_import_modules.py b/pym/portage/tests/lint/test_import_modules.py new file mode 100644 index 000000000..cee579a3a --- /dev/null +++ b/pym/portage/tests/lint/test_import_modules.py @@ -0,0 +1,35 @@ +# Copyright 2011 Gentoo Foundation +# Distributed under the terms of the GNU General Public License v2 + +from portage.const import PORTAGE_PYM_PATH +from portage.tests import TestCase +from portage import os +from portage import _encodings +from portage import _unicode_decode + +class ImportModulesTestCase(TestCase): + + def testImportModules(self): + for mod in self._list_modules(PORTAGE_PYM_PATH): + __import__(mod) + + def _list_modules(self, base_dir): + all_modules = [] + for parent, dirs, files in os.walk(base_dir): + parent = _unicode_decode(parent, + encoding=_encodings['fs'], errors='strict') + parent_mod = parent[len(PORTAGE_PYM_PATH)+1:] + parent_mod = parent_mod.replace("/", ".") + for x in files: + x = _unicode_decode(x, + encoding=_encodings['fs'], errors='strict') + if x[-3:] != '.py': + continue + x = x[:-3] + if x[-8:] == '__init__': + x = parent_mod + else: + x = parent_mod + "." + x + all_modules.append(x) + + return all_modules |