1
0
forked from VimPlug/jedi

Move dummy pyc to dummy package

This commit is contained in:
ColinDuquesnoy
2014-02-18 19:18:17 +01:00
parent 18a31dcbf1
commit 5a706265bc

View File

@@ -23,19 +23,23 @@ class Bar:
def generate_pyc():
with open("dummy.py", 'w') as f:
os.mkdir("dummy_package")
with open("dummy_package/__init__.py", 'w'):
pass
with open("dummy_package/dummy.py", 'w') as f:
f.write(SRC)
compileall.compile_file("dummy.py")
os.remove("dummy.py")
compileall.compile_file("dummy_package/dummy.py")
os.remove("dummy_package/dummy.py")
if sys.version_info[0] == 3:
# Python3 specific:
# To import pyc modules, we must move them out of the __pycache__
# directory and rename them to remove ".cpython-%s%d"
# see: http://stackoverflow.com/questions/11648440/python-does-not-detect-pyc-files
for f in os.listdir("__pycache__"):
for f in os.listdir("dummy_package/__pycache__"):
dst = f.replace('.cpython-%s%s' % sys.version_info[:2], "")
shutil.copy(os.path.join("__pycache__", f), dst)
dst = os.path.join("dummy_package", dst)
shutil.copy(os.path.join("dummy_package/__pycache__", f), dst)
def test_pyc():
@@ -43,8 +47,9 @@ def test_pyc():
The list of completion must be greater than 2.
"""
generate_pyc()
s = jedi.Script("import dummy; dummy.")
s = jedi.Script("from dummy_package import dummy; dummy.")
assert len(s.completions()) >= 2
shutil.rmtree("dummy_package")
if __name__ == "__main__":