Commit 7440ba4b authored by Stefan Behnel's avatar Stefan Behnel

Extend module reimport test to also try reimports without knowing the package.

parent 4bcb6d1c
# mode: run
# tag: pep489
PYTHON setup.py build_ext --inplace PYTHON setup.py build_ext --inplace
PYTHON -c "import a" PYTHON -c "import a"
...@@ -35,6 +38,7 @@ assert sys.modules['atest.package.module'] is module, list(sys.modules) ...@@ -35,6 +38,7 @@ assert sys.modules['atest.package.module'] is module, list(sys.modules)
if sys.version_info >= (3, 5): if sys.version_info >= (3, 5):
from . import pymodule from . import pymodule
assert module is pymodule.import_without_package()
######## atest/package/pymodule.py ######## ######## atest/package/pymodule.py ########
...@@ -43,3 +47,13 @@ from ..package import module ...@@ -43,3 +47,13 @@ from ..package import module
import atest.package.module import atest.package.module
import a import a
def import_without_package():
import os.path
import sys
sys.path.insert(0, os.path.dirname(__file__))
sys.path.insert(0, os.path.dirname(os.path.dirname(__file__)))
import module
import package.module
assert package.module is module
return module
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment