forked from VimPlug/jedi
Add test pyc
Should succeed for python2 and faild for python3
This commit is contained in:
38
test/test_pyc.py
Normal file
38
test/test_pyc.py
Normal file
@@ -0,0 +1,38 @@
|
|||||||
|
"""
|
||||||
|
Test completions from *.pyc files:
|
||||||
|
|
||||||
|
- generated a dummy python module
|
||||||
|
- compile the dummy module to generate a *.pyc
|
||||||
|
- delete the pure python dummy module
|
||||||
|
- try jedi on the generated *.pyc
|
||||||
|
"""
|
||||||
|
import os
|
||||||
|
import compileall
|
||||||
|
import jedi
|
||||||
|
|
||||||
|
SRC = """class Foo:
|
||||||
|
pass
|
||||||
|
|
||||||
|
class Bar:
|
||||||
|
pass
|
||||||
|
"""
|
||||||
|
|
||||||
|
|
||||||
|
def generate_pyc():
|
||||||
|
with open("dummy.py", 'w') as f:
|
||||||
|
f.write(SRC)
|
||||||
|
compileall.compile_file("dummy.py")
|
||||||
|
os.remove("dummy.py")
|
||||||
|
|
||||||
|
|
||||||
|
def test_pyc():
|
||||||
|
"""
|
||||||
|
The list of completion must be greater than 2.
|
||||||
|
"""
|
||||||
|
generate_pyc()
|
||||||
|
s = jedi.Script("import dummy; dummy.")
|
||||||
|
assert len(s.completions()) >= 2
|
||||||
|
|
||||||
|
|
||||||
|
if __name__ == "__main__":
|
||||||
|
test_pyc()
|
||||||
Reference in New Issue
Block a user