コード例 #1
0
ファイル: factories.py プロジェクト: abster12/dotfiles
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)
コード例 #2
0
ファイル: test_environment.py プロジェクト: steff456/jedi
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
コード例 #3
0
ファイル: conftest.py プロジェクト: syntonym/jedi
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))
コード例 #4
0
ファイル: factories.py プロジェクト: srusskih/SublimeJEDI
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)
コード例 #5
0
ファイル: conftest.py プロジェクト: Marslo/VimConfig
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:])
コード例 #6
0
ファイル: conftest.py プロジェクト: KohsukeKubota/dotfiles
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:])
コード例 #7
0
    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)
コード例 #8
0
    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)
コード例 #9
0
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'
コード例 #10
0
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'
コード例 #11
0
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
コード例 #12
0
            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
コード例 #13
0
ファイル: run.py プロジェクト: BlackArch/blackarch-iso
            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
コード例 #14
0
ファイル: project.py プロジェクト: syntonym/jedi
    def get_environment(self):
        if self._environment is None:
            return get_default_environment()

        return self._environment
コード例 #15
0
ファイル: test_environment.py プロジェクト: steff456/jedi
def test_working_venv(venv_path, monkeypatch):
    monkeypatch.setenv('VIRTUAL_ENV', venv_path)
    assert get_default_environment().path == venv_path
コード例 #16
0
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
コード例 #17
0
def test_virtualenv():
    with set_environment_variable('VIRTUAL_ENV', '/foo/bar/jedi_baz'):
        assert get_default_environment()._executable == sys.executable
コード例 #18
0
def test_working_venv(venv_path, monkeypatch):
    monkeypatch.setenv('VIRTUAL_ENV', venv_path)
    assert get_default_environment().path == venv_path
コード例 #19
0
def test_working_venv(venv_path):
    with set_environment_variable('VIRTUAL_ENV', venv_path):
        assert get_default_environment().path == venv_path
コード例 #20
0
def test_sys_path():
    assert get_default_environment().get_sys_path()
コード例 #21
0
ファイル: test_environment.py プロジェクト: steff456/jedi
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