mirror of
https://github.com/davidhalter/jedi.git
synced 2026-02-20 15:58:26 +08:00
Merge remote-tracking branch 'origin/master' into typeshed
This commit is contained in:
@@ -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]
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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'
|
||||
|
||||
Reference in New Issue
Block a user