def build_facade(source, line, column): env = environment.get_default_environment() return facade.JediFacade(env, 'complete', source, line, column, sys_path=env.get_sys_path)
def test_get_default_environment_when_embedded(monkeypatch, virtualenv): # When using Python embedded, sometimes the executable is not a Python # executable. executable_name = 'RANDOM_EXE' monkeypatch.setattr(sys, 'executable', executable_name) monkeypatch.setenv('VIRTUAL_ENV', virtualenv) env = get_default_environment() assert env.executable != executable_name
def environment(request): version = request.config.option.env if version is None: version = os.environ.get('JEDI_TEST_ENVIRONMENT', str(py_version)) if int(version) == py_version: return get_default_environment() return get_python_environment('python%s.%s' % tuple(version))
def build_facade(source, line, column): env = environment.get_default_environment() return facade.JediFacade( env, 'complete', source, line, column, sys_path=env.get_sys_path)
def environment(request): version = request.config.option.env if version is None: version = os.environ.get('JEDI_TEST_ENVIRONMENT', str(py_version)) if int(version) == py_version: return get_default_environment() return get_system_environment(version[0] + '.' + version[1:])
def test_should_return_function_parameters_also(self): env = environment.get_default_environment() f = facade.JediFacade( env, 'complete', COMPLETION_TEST, 3, 6, sys_path=env.get_sys_path) completions = f.get_autocomplete() assert completions self.assertIn(('var1\tparam', 'var1'), completions) self.assertIn(('var2\tparam', 'var2'), completions)
def test_should_return_function_parameters_also(self): env = environment.get_default_environment() f = facade.JediFacade(env, 'complete', COMPLETION_TEST, 3, 6, sys_path=env.get_sys_path) completions = f.get_autocomplete() assert completions self.assertIn(('var1\tparam', 'var1'), completions) self.assertIn(('var2\tparam', 'var2'), completions)
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'
def test_not_existing_virtualenv(): """Should not match the path that was given""" path = '/foo/bar/jedi_baz' with set_environment_variable('VIRTUAL_ENV', path): assert get_default_environment().executable != path
current = os.path.basename(current) print('{:25} {} tests and {} fails.'.format(current, tests, fails)) def report(case, actual, desired): if actual == desired: return 0 else: print("\ttest fail @%d, actual = %s, desired = %s" % (case.line_nr - 1, actual, desired)) return 1 if arguments['--env']: environment = get_system_environment(arguments['--env']) else: # Will be 3.6. environment = get_default_environment() import traceback current = cases[0].path if cases else None count = fails = 0 for c in cases: if c.get_skip_reason(environment): continue if current != c.path: file_change(current, count, fails) current = c.path count = fails = 0 try: if c.run(report, environment): tests_fail += 1
current = os.path.basename(current) print('%s \t\t %s tests and %s fails.' % (current, tests, fails)) def report(case, actual, desired): if actual == desired: return 0 else: print("\ttest fail @%d, actual = %s, desired = %s" % (case.line_nr - 1, actual, desired)) return 1 if arguments['--env']: environment = get_system_environment(arguments['--env']) else: # Will be 3.6. environment = get_default_environment() import traceback current = cases[0].path if cases else None count = fails = 0 for c in cases: if c.get_skip_reason(environment): continue if current != c.path: file_change(current, count, fails) current = c.path count = fails = 0 try: if c.run(report, environment): tests_fail += 1
def get_environment(self): if self._environment is None: return get_default_environment() return self._environment
def test_working_venv(venv_path, monkeypatch): monkeypatch.setenv('VIRTUAL_ENV', venv_path) assert get_default_environment().path == venv_path
def test_not_existing_virtualenv(monkeypatch): """Should not match the path that was given""" path = '/foo/bar/jedi_baz' monkeypatch.setenv('VIRTUAL_ENV', path) assert get_default_environment().executable != path
def test_virtualenv(): with set_environment_variable('VIRTUAL_ENV', '/foo/bar/jedi_baz'): assert get_default_environment()._executable == sys.executable
def test_working_venv(venv_path): with set_environment_variable('VIRTUAL_ENV', venv_path): assert get_default_environment().path == venv_path
def test_sys_path(): assert get_default_environment().get_sys_path()