Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
C
cython
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Kirill Smelkov
cython
Commits
e914b27b
Commit
e914b27b
authored
Mar 16, 2013
by
Stefan Behnel
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
add test for absolute imports
parent
335a1b21
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
60 additions
and
0 deletions
+60
-0
runtests.py
runtests.py
+1
-0
tests/run/absolute_import.srctree
tests/run/absolute_import.srctree
+59
-0
No files found.
runtests.py
View file @
e914b27b
...
...
@@ -201,6 +201,7 @@ VER_DEP_MODULES = {
'run.yield_from_pep380', # GeneratorExit
'run.generator_frame_cycle', # yield in try-finally
'run.generator_expressions_in_class',
'run.absolute_import',
'run.relativeimport_T542',
'run.relativeimport_star_T542',
'run.initial_file_path', # relative import
...
...
tests/run/absolute_import.srctree
0 → 100644
View file @
e914b27b
PYTHON setup.py build_ext --inplace
PYTHON -c "import pkg.my_test_module"
PYTHON -c "import pkg.b; pkg.b.test_reimport()"
PYTHON -c "import pkg.c; pkg.c.test_reimport()"
######## setup.py ########
from Cython.Build.Dependencies import cythonize
from distutils.core import setup
setup(
ext_modules = cythonize("**/*.pyx"),
)
######## pkg/__init__.py ########
######## pkg/a_module.pyx ########
######## pkg/my_test_module.pyx ########
import sys
from . import a_module
assert a_module in sys.modules.values(), list(sys.modules)
assert sys.modules['pkg.a_module'] is a_module, list(sys.modules)
######## pkg/b.pyx ########
from __future__ import absolute_import
import sys
try:
import my_test_module
except ImportError:
pass
else:
assert "expected ImportError on absolute import"
import pkg.my_test_module
assert pkg.my_test_module in sys.modules.values(), list(sys.modules)
assert sys.modules['pkg.my_test_module'] is pkg.my_test_module, list(sys.modules)
def test_reimport():
import pkg.my_test_module as mod
assert pkg.my_test_module is mod
######## pkg/c.pyx ########
from __future__ import absolute_import
import sys
from pkg import my_test_module
assert my_test_module in sys.modules.values(), list(sys.modules)
assert sys.modules['pkg.my_test_module'] is my_test_module, list(sys.modules)
def test_reimport():
from pkg import my_test_module as mod
assert my_test_module is mod
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment