Author: Ronan Lamy <ronan.l...@gmail.com> Branch: test-cpyext Changeset: r86965:2224e01830ae Date: 2016-09-08 18:15 +0100 http://bitbucket.org/pypy/pypy/changeset/2224e01830ae/
Log: Simplify load_it=False logic in import_module() diff --git a/pypy/module/cpyext/test/test_cpyext.py b/pypy/module/cpyext/test/test_cpyext.py --- a/pypy/module/cpyext/test/test_cpyext.py +++ b/pypy/module/cpyext/test/test_cpyext.py @@ -178,6 +178,7 @@ return arg listview = passthrough str_w = passthrough + wrap = passthrough def unwrap(self, args): try: @@ -391,22 +392,18 @@ mod = self.sys_info.compile_extension_module( name, include_dirs=include_dirs, **kwds) - if load_it: - if self.runappdirect: - import imp - return imp.load_dynamic(name, mod) - else: - api.load_extension_module(space, mod, name) - self.imported_module_names.append(name) - return space.getitem( - space.sys.get('modules'), - space.wrap(name)) + if not load_it: + return space.wrap(mod) + if self.runappdirect: + import imp + return imp.load_dynamic(name, mod) else: - path = os.path.dirname(mod) - if self.runappdirect: - return path - else: - return space.wrap(path) + api.load_extension_module(space, mod, name) + self.imported_module_names.append(name) + return space.getitem( + space.sys.get('modules'), + space.wrap(name)) + @gateway.unwrap_spec(mod=str, name=str) def reimport_module(space, mod, name): diff --git a/pypy/module/cpyext/test/test_import.py b/pypy/module/cpyext/test/test_import.py --- a/pypy/module/cpyext/test/test_import.py +++ b/pypy/module/cpyext/test/test_import.py @@ -1,6 +1,6 @@ from pypy.module.cpyext.test.test_api import BaseApiTest from pypy.module.cpyext.test.test_cpyext import AppTestCpythonExtensionBase -from rpython.rtyper.lltypesystem import rffi, lltype +from rpython.rtyper.lltypesystem import rffi class TestImport(BaseApiTest): def test_import(self, space, api): @@ -39,9 +39,8 @@ class AppTestImportLogic(AppTestCpythonExtensionBase): def test_import_logic(self): + import sys, os path = self.import_module(name='test_import_module', load_it=False) - import sys - sys.path.append(path) + sys.path.append(os.path.dirname(path)) import test_import_module assert test_import_module.TEST is None - _______________________________________________ pypy-commit mailing list pypy-commit@python.org https://mail.python.org/mailman/listinfo/pypy-commit