From ea43efc9d820833090670305a73543b43cf4286b Mon Sep 17 00:00:00 2001 From: ColinDuquesnoy Date: Tue, 18 Feb 2014 18:58:22 +0100 Subject: [PATCH] Fix pyc test for python3 To import pyc modules, we must move them out of the __pycache__ directory and rename them to remove ".cpython-%s%d". This should still faild with python3 (UnicodeDecodeError) --- test/test_pyc.py | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) diff --git a/test/test_pyc.py b/test/test_pyc.py index 74c39642..22840502 100644 --- a/test/test_pyc.py +++ b/test/test_pyc.py @@ -1,15 +1,19 @@ """ Test completions from *.pyc files: - - generated a dummy python module + - generate 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 os +import shutil +import sys + import jedi + SRC = """class Foo: pass @@ -24,6 +28,15 @@ def generate_pyc(): compileall.compile_file("dummy.py") os.remove("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__"): + dst = f.replace('.cpython-%s%s' % sys.version_info[:2], "") + shutil.copy(os.path.join("__pycache__", f), dst) + def test_pyc(): """