Commit 705a1db2 authored by Stefan Behnel's avatar Stefan Behnel

rewrite hackish test to make it work in Py3.5

parent 708875fa
# cython: language_level=3
import sys
# fool Python we are in distutils
if sys.version_info >= (3,):
__name__='distutils.cytest_relativeimport_T542'
else:
__name__=b'distutils.cytest_relativeimport_T542'
from distutils import cmd, core, version
from .core import *
def test_relative():
"""
>>> test_relative() == (cmd, core, 'distutils.version')
True
"""
from . import cmd, core
from . import (version, core)
from . import (version, core,)
from .version import __name__
return cmd, core, __name__
def test_absolute():
"""
>>> test_absolute() # doctest: +ELLIPSIS
Traceback (most recent call last):
ImportError: No module named ...debug...
"""
import debug
return
__doc__ = """
>>> setup == core.setup
True
"""
# mode: run
# tag: import
"""
PYTHON setup.py build_ext -i
PYTHON test_relative_import.py
"""
######## setup.py ########
from Cython.Build.Dependencies import cythonize
from distutils.core import setup
setup(
ext_modules = cythonize("*/*.pyx"),
)
######## test_relative_import.py ########
from relimport.testmod import test_relative, test_absolute
a, bmod, afunc, bfunc = test_relative()
try:
test_absolute()
except ImportError:
pass
else:
assert False, "absolute import succeeded"
import relimport.a
import relimport.bmod
import relimport.testmod
assert relimport.a == a
assert relimport.bmod == bmod
assert afunc() == 'a', afunc
assert bfunc() == 'b', bfunc
######## relimport/__init__.py ########
######## relimport/a.pyx ########
def afunc(): return 'a'
######## relimport/bmod.pyx ########
def bfunc(): return 'b'
######## relimport/testmod.pyx ########
# cython: language_level=3
from relimport import a, bmod
from . import *
def test_relative():
from . import a, bmod
from . import (a, bmod)
from . import (a, bmod,)
from .a import afunc
from .bmod import bfunc
assert afunc() == 'a', afunc()
assert bfunc() == 'b', bfunc()
return a, bmod, afunc, bfunc
def test_absolute():
import bmod
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