1
0
forked from VimPlug/jedi

python 2 compatibility (also with the new travis build)

This commit is contained in:
Dave Halter
2014-05-04 11:50:13 +02:00
parent 02b98ad4e4
commit ef62904af3
3 changed files with 11 additions and 5 deletions

View File

@@ -408,6 +408,7 @@ class _Importer(object):
path += '/__init__.py'
with open(path, 'rb') as f:
source = f.read()
source = source.replace(b'\n', b'\r\n')
else:
source = current_namespace[0].read()
current_namespace[0].close()

View File

@@ -6,11 +6,12 @@ Test completions from *.pyc files:
- delete the pure python dummy module
- try jedi on the generated *.pyc
"""
import compileall
import os
import shutil
import sys
import pytest
import jedi
from ..helpers import cwd_at
@@ -29,6 +30,7 @@ def generate_pyc():
pass
with open("dummy_package/dummy.py", 'w') as f:
f.write(SRC)
import compileall
compileall.compile_file("dummy_package/dummy.py")
os.remove("dummy_package/dummy.py")
@@ -43,6 +45,8 @@ def generate_pyc():
shutil.copy(os.path.join("dummy_package/__pycache__", f), dst)
# Python 2.6 does not necessarily come with `compileall.compile_file`.
@pytest.mark.skipif("sys.version_info > (2,6)")
@cwd_at('test/test_evaluate')
def test_pyc():
"""

View File

@@ -1,6 +1,7 @@
from textwrap import dedent
import jedi
from jedi._compatibility import u
from jedi.parser.fast import FastParser
@@ -42,7 +43,7 @@ def test_class_in_docstr():
def test_carriage_return_splitting():
source = dedent('''
source = u(dedent('''
@@ -50,7 +51,7 @@ def test_carriage_return_splitting():
class Foo():
pass
''')
'''))
source = source.replace('\n', '\r\n')
p = FastParser(source)
assert [str(n) for n in p.module.get_defined_names()] == ['Foo']