Merge remote-tracking branch 'origin/master' into typeshed

This commit is contained in:
Dave Halter
2018-09-24 00:16:13 +02:00
8 changed files with 118 additions and 34 deletions

View File

@@ -131,3 +131,46 @@ set_t2 = set()
#? ['clear', 'copy']
set_t2.c
# -----------------
# pep 448 unpacking generalizations
# -----------------
# python >= 3.5
d = {'a': 3}
#? dict()
{**d}
#? str()
{**d, "b": "b"}["b"]
# Should resolve to int() but jedi is not smart enough yet
# Here to make sure it doesn't result in crash though
#?
{**d}["a"]
s = {1, 2, 3}
#? set()
{*s}
#? set()
{*s, 4, *s}
s = {1, 2, 3}
# Should resolve to int() but jedi is not smart enough yet
# Here to make sure it doesn't result in crash though
#?
{*s}.pop()
#? int()
{*s, 4}.pop()
# Should resolve to int() but jedi is not smart enough yet
# Here to make sure it doesn't result in crash though
#?
[*s][0]
#? int()
[*s, 4][0]

View File

@@ -126,11 +126,12 @@ class StaticAnalysisCase(object):
return "<%s: %s>" % (self.__class__.__name__, os.path.basename(self._path))
@pytest.fixture()
def venv_path(tmpdir, environment):
@pytest.fixture(scope='session')
def venv_path(tmpdir_factory, environment):
if environment.version_info.major < 3:
pytest.skip("python -m venv does not exist in Python 2")
tmpdir = tmpdir_factory.mktemp('venv_path')
dirname = os.path.join(tmpdir.dirname, 'venv')
# We cannot use the Python from tox because tox creates virtualenvs and

View File

@@ -110,3 +110,22 @@ def test_create_environment_venv_path(venv_path):
def test_create_environment_executable():
environment = create_environment(sys.executable)
assert environment.executable == sys.executable
def test_get_default_environment_from_env_does_not_use_safe(tmpdir, monkeypatch):
fake_python = os.path.join(str(tmpdir), 'fake_python')
with open(fake_python, 'w') as f:
f.write('')
def _get_subprocess(self):
if self._start_executable != fake_python:
raise RuntimeError('Should not get called!')
self.executable = fake_python
self.path = 'fake'
monkeypatch.setattr('jedi.api.environment.Environment._get_subprocess',
_get_subprocess)
monkeypatch.setenv('VIRTUAL_ENV', fake_python)
env = get_default_environment()
assert env.path == 'fake'