diff options
-rw-r--r-- | pym/portage/tests/lint/test_compile_modules.py | 17 |
1 files changed, 15 insertions, 2 deletions
diff --git a/pym/portage/tests/lint/test_compile_modules.py b/pym/portage/tests/lint/test_compile_modules.py index 2e5ab7e2d..5b86fcfb2 100644 --- a/pym/portage/tests/lint/test_compile_modules.py +++ b/pym/portage/tests/lint/test_compile_modules.py @@ -1,6 +1,7 @@ -# Copyright 2009 Gentoo Foundation +# Copyright 2009-2010 Gentoo Foundation # Distributed under the terms of the GNU General Public License v2 +import imp import itertools import stat @@ -45,6 +46,18 @@ class CompileModulesTestCase(TestCase): do_compile = True cfile += '.py' if do_compile: - cfile += (__debug__ and 'c' or 'o') + try: + # Python >=3.2 + cfile = imp.cache_from_source(cfile) + except AttributeError: + cfile += (__debug__ and 'c' or 'o') py_compile.compile(x, cfile=cfile, doraise=True) os.unlink(cfile) + cfile_parent_dir = os.path.dirname(cfile) + if os.path.basename(cfile_parent_dir) == '__pycache__': + # Python >=3.2 + try: + os.rmdir(cfile_parent_dir) + except OSError: + # __pycache__ directory is non-empty. + pass |