forked from VimPlug/jedi
python 2 compatibility (also with the new travis build)
This commit is contained in:
@@ -408,6 +408,7 @@ class _Importer(object):
|
|||||||
path += '/__init__.py'
|
path += '/__init__.py'
|
||||||
with open(path, 'rb') as f:
|
with open(path, 'rb') as f:
|
||||||
source = f.read()
|
source = f.read()
|
||||||
|
source = source.replace(b'\n', b'\r\n')
|
||||||
else:
|
else:
|
||||||
source = current_namespace[0].read()
|
source = current_namespace[0].read()
|
||||||
current_namespace[0].close()
|
current_namespace[0].close()
|
||||||
|
|||||||
@@ -6,11 +6,12 @@ Test completions from *.pyc files:
|
|||||||
- delete the pure python dummy module
|
- delete the pure python dummy module
|
||||||
- try jedi on the generated *.pyc
|
- try jedi on the generated *.pyc
|
||||||
"""
|
"""
|
||||||
import compileall
|
|
||||||
import os
|
import os
|
||||||
import shutil
|
import shutil
|
||||||
import sys
|
import sys
|
||||||
|
|
||||||
|
import pytest
|
||||||
|
|
||||||
import jedi
|
import jedi
|
||||||
from ..helpers import cwd_at
|
from ..helpers import cwd_at
|
||||||
|
|
||||||
@@ -29,6 +30,7 @@ def generate_pyc():
|
|||||||
pass
|
pass
|
||||||
with open("dummy_package/dummy.py", 'w') as f:
|
with open("dummy_package/dummy.py", 'w') as f:
|
||||||
f.write(SRC)
|
f.write(SRC)
|
||||||
|
import compileall
|
||||||
compileall.compile_file("dummy_package/dummy.py")
|
compileall.compile_file("dummy_package/dummy.py")
|
||||||
os.remove("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)
|
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')
|
@cwd_at('test/test_evaluate')
|
||||||
def test_pyc():
|
def test_pyc():
|
||||||
"""
|
"""
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
from textwrap import dedent
|
from textwrap import dedent
|
||||||
|
|
||||||
import jedi
|
import jedi
|
||||||
|
from jedi._compatibility import u
|
||||||
from jedi.parser.fast import FastParser
|
from jedi.parser.fast import FastParser
|
||||||
|
|
||||||
|
|
||||||
@@ -42,7 +43,7 @@ def test_class_in_docstr():
|
|||||||
|
|
||||||
|
|
||||||
def test_carriage_return_splitting():
|
def test_carriage_return_splitting():
|
||||||
source = dedent('''
|
source = u(dedent('''
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@@ -50,7 +51,7 @@ def test_carriage_return_splitting():
|
|||||||
|
|
||||||
class Foo():
|
class Foo():
|
||||||
pass
|
pass
|
||||||
''')
|
'''))
|
||||||
source = source.replace('\n', '\r\n')
|
source = source.replace('\n', '\r\n')
|
||||||
p = FastParser(source)
|
p = FastParser(source)
|
||||||
assert [str(n) for n in p.module.get_defined_names()] == ['Foo']
|
assert [str(n) for n in p.module.get_defined_names()] == ['Foo']
|
||||||
|
|||||||
Reference in New Issue
Block a user