Merge branch 'master' into typeshed

This commit is contained in:
Dave Halter
2018-08-04 23:42:17 +02:00
23 changed files with 210 additions and 140 deletions

View File

@@ -437,7 +437,7 @@ def test_func():
#? int()
tuple({1})[0]
# python >= 3.3
# python >= 3.4
# -----------------
# PEP 3132 Extended Iterable Unpacking (star unpacking)
# -----------------

View File

@@ -417,6 +417,9 @@ class PrivateVar():
def __private_func(self):
return 1
#? int()
__private_func()
def wrap_private(self):
return self.__private_func()
#? []
@@ -425,6 +428,8 @@ PrivateVar().__var
PrivateVar().__var
#? []
PrivateVar().__private_func
#? []
PrivateVar.__private_func
#? int()
PrivateVar().wrap_private()

View File

@@ -220,7 +220,7 @@ def x():
# yield from
# -----------------
# python >= 3.3
# python >= 3.4
def yield_from():
yield from iter([1])

View File

@@ -1,6 +1,6 @@
""" Pep-0484 type hinting """
# python >= 3.2
# python >= 3.4
class A():

View File

@@ -243,7 +243,7 @@ for key in x.keys():
for value in x.values():
#? int()
value
# python >= 3.2
# python >= 3.4
class TestDefaultDict(typing.DefaultDict[str, int]):
def setdud(self):
@@ -271,7 +271,7 @@ for key in x.keys():
for value in x.values():
#? int()
value
# python >= 3.2
# python >= 3.4
"""

View File

@@ -6,7 +6,7 @@ import pytest
from ..helpers import TestCase
from jedi import cache
from jedi._compatibility import is_py33
from jedi._compatibility import is_py3
def assert_signature(Script, source, expected_name, expected_index=0, line=None, column=None):
@@ -247,7 +247,7 @@ def _params(Script, source, line=None, column=None):
def test_param_name(Script):
if not is_py33:
if not is_py3:
p = _params(Script, '''int(''')
# int is defined as: `int(x[, base])`
assert p[0].name == 'x'

View File

@@ -10,8 +10,10 @@ import os
import shutil
import sys
import pytest
import jedi
from ..helpers import cwd_at
from jedi.api.environment import SameEnvironment
SRC = """class Foo:
@@ -22,35 +24,44 @@ class Bar:
"""
def generate_pyc():
os.mkdir("dummy_package")
with open("dummy_package/__init__.py", 'w'):
@pytest.fixture
def pyc_project_path(tmpdir):
path = tmpdir.strpath
dummy_package_path = os.path.join(path, "dummy_package")
os.mkdir(dummy_package_path)
with open(os.path.join(dummy_package_path, "__init__.py"), 'w'):
pass
with open("dummy_package/dummy.py", 'w') as f:
dummy_path = os.path.join(dummy_package_path, 'dummy.py')
with open(dummy_path, 'w') as f:
f.write(SRC)
import compileall
compileall.compile_file("dummy_package/dummy.py")
os.remove("dummy_package/dummy.py")
compileall.compile_file(dummy_path)
os.remove(dummy_path)
if sys.version_info[0] == 3:
if sys.version_info.major == 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("dummy_package/__pycache__"):
pycache = os.path.join(dummy_package_path, "__pycache__")
for f in os.listdir(pycache):
dst = f.replace('.cpython-%s%s' % sys.version_info[:2], "")
dst = os.path.join("dummy_package", dst)
shutil.copy(os.path.join("dummy_package/__pycache__", f), dst)
dst = os.path.join(dummy_package_path, dst)
shutil.copy(os.path.join(pycache, f), dst)
try:
yield path
finally:
shutil.rmtree(path)
@cwd_at('test/test_evaluate')
def test_pyc(Script):
def test_pyc(pyc_project_path):
"""
The list of completion must be greater than 2.
"""
try:
generate_pyc()
s = jedi.Script("from dummy_package import dummy; dummy.", path='blub.py')
assert len(s.completions()) >= 2
finally:
shutil.rmtree("dummy_package")
path = os.path.join(pyc_project_path, 'blub.py')
s = jedi.Script(
"from dummy_package import dummy; dummy.",
path=path,
environment=SameEnvironment())
assert len(s.completions()) >= 2