1
0
forked from VimPlug/jedi

use _ctypes for extension tests

This commit is contained in:
Akinori Hattori
2014-07-19 14:39:14 +09:00
parent 10b7ed967d
commit 712e5653d8
8 changed files with 17 additions and 50 deletions

View File

@@ -2,41 +2,30 @@
Test compiled module
"""
import os
import platform
import sys
import jedi
from ..helpers import cwd_at
@cwd_at('test/test_evaluate/extensions')
def test_completions():
if platform.architecture()[0] == '64bit':
package_name = "compiled%s%s" % sys.version_info[:2]
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
s = jedi.Script('import _ctypes; _ctypes.')
assert len(s.completions()) >= 15
@cwd_at('test/test_evaluate/extensions')
def test_call_signatures_extension():
# with a cython extension
if platform.architecture()[0] == '64bit':
package_name = "compiled%s%s" % sys.version_info[:2]
sys.path.insert(0, os.getcwd())
if os.path.exists(package_name):
s = jedi.Script("from %s import compiled; compiled.Foo(" %
package_name)
defs = s.call_signatures()
for call_def in defs:
for param in call_def.params:
pass
if os.name == 'nt':
func = 'LoadLibrary'
params = 1
else:
func = 'dlopen'
params = 2
s = jedi.Script('import _ctypes; _ctypes.%s(' % (func,))
sigs = s.call_signatures()
assert len(sigs) == 1
assert len(sigs[0].params) == params
def test_call_signatures_stdlib():
code = "import math; math.cos("
s = jedi.Script(code)
defs = s.call_signatures()
for call_def in defs:
assert len(call_def.params) == 1
s = jedi.Script('import math; math.cos(')
sigs = s.call_signatures()
assert len(sigs) == 1
assert len(sigs[0].params) == 1