mirror of
https://github.com/davidhalter/jedi.git
synced 2025-12-15 01:57:06 +08:00
use _ctypes for extension tests
This commit is contained in:
@@ -1,10 +0,0 @@
|
|||||||
This directory contains pre-compiled extensions modules used to test completions
|
|
||||||
for compiled modules on Travis-CI (Ubuntu 12.04 64bit).
|
|
||||||
|
|
||||||
To build the extensions modules, run::
|
|
||||||
|
|
||||||
python setup.py build_ext -i
|
|
||||||
|
|
||||||
|
|
||||||
Then move the compiled modules to their testing package ( ./**compiledXX**, where XX is the
|
|
||||||
python version used to run setup.py).
|
|
||||||
@@ -1,6 +0,0 @@
|
|||||||
cdef class Foo:
|
|
||||||
pass
|
|
||||||
|
|
||||||
|
|
||||||
cdef class Bar:
|
|
||||||
pass
|
|
||||||
Binary file not shown.
Binary file not shown.
@@ -1,6 +0,0 @@
|
|||||||
from distutils.core import setup
|
|
||||||
from Cython.Build import cythonize
|
|
||||||
|
|
||||||
setup(
|
|
||||||
ext_modules=cythonize("compiled.pyx")
|
|
||||||
)
|
|
||||||
@@ -2,41 +2,30 @@
|
|||||||
Test compiled module
|
Test compiled module
|
||||||
"""
|
"""
|
||||||
import os
|
import os
|
||||||
import platform
|
|
||||||
import sys
|
|
||||||
import jedi
|
import jedi
|
||||||
|
|
||||||
from ..helpers import cwd_at
|
|
||||||
|
|
||||||
|
|
||||||
@cwd_at('test/test_evaluate/extensions')
|
|
||||||
def test_completions():
|
def test_completions():
|
||||||
if platform.architecture()[0] == '64bit':
|
s = jedi.Script('import _ctypes; _ctypes.')
|
||||||
package_name = "compiled%s%s" % sys.version_info[:2]
|
assert len(s.completions()) >= 15
|
||||||
sys.path.insert(0, os.getcwd())
|
|
||||||
if os.path.exists(package_name):
|
|
||||||
s = jedi.Script("from %s import compiled; compiled." % package_name)
|
|
||||||
assert len(s.completions()) >= 2
|
|
||||||
|
|
||||||
|
|
||||||
@cwd_at('test/test_evaluate/extensions')
|
|
||||||
def test_call_signatures_extension():
|
def test_call_signatures_extension():
|
||||||
# with a cython extension
|
if os.name == 'nt':
|
||||||
if platform.architecture()[0] == '64bit':
|
func = 'LoadLibrary'
|
||||||
package_name = "compiled%s%s" % sys.version_info[:2]
|
params = 1
|
||||||
sys.path.insert(0, os.getcwd())
|
else:
|
||||||
if os.path.exists(package_name):
|
func = 'dlopen'
|
||||||
s = jedi.Script("from %s import compiled; compiled.Foo(" %
|
params = 2
|
||||||
package_name)
|
s = jedi.Script('import _ctypes; _ctypes.%s(' % (func,))
|
||||||
defs = s.call_signatures()
|
sigs = s.call_signatures()
|
||||||
for call_def in defs:
|
assert len(sigs) == 1
|
||||||
for param in call_def.params:
|
assert len(sigs[0].params) == params
|
||||||
pass
|
|
||||||
|
|
||||||
|
|
||||||
def test_call_signatures_stdlib():
|
def test_call_signatures_stdlib():
|
||||||
code = "import math; math.cos("
|
s = jedi.Script('import math; math.cos(')
|
||||||
s = jedi.Script(code)
|
sigs = s.call_signatures()
|
||||||
defs = s.call_signatures()
|
assert len(sigs) == 1
|
||||||
for call_def in defs:
|
assert len(sigs[0].params) == 1
|
||||||
assert len(call_def.params) == 1
|
|
||||||
|
|||||||
Reference in New Issue
Block a user