def test_connection_dialog_doesnt_remember_input_with_ssh_passphrase( qtbot, connection_dialog_factory): """ Test that the dialog doesn't remember the user's kernel connection settings and ssh key passphrase when the user doesn't check the save checkbox. """ dlg = connection_dialog_factory.submit_filled_dialog(use_keyfile=True, save_settings=False) # Press ok and save connection settings qtbot.mouseClick(dlg.accept_btns.button(QDialogButtonBox.Ok), Qt.LeftButton) # create new dialog and check fields new_dlg = connection_dialog_factory.get_default_dialog() assert new_dlg.cf.text() == "" assert not new_dlg.rm_group.isChecked() assert new_dlg.hn.text() == "" assert new_dlg.un.text() == "" assert new_dlg.pn.text() == "22" assert new_dlg.kf.text() == "" if not running_in_ci(): assert new_dlg.kfp.text() == ""
def register_all_providers(): """Create a entry points distribution to register all the providers.""" # This is not necessary in CIs if running_in_ci(): return fallback = pkg_resources.EntryPoint.parse( 'fallback = spyder.plugins.completion.providers.fallback.provider:' 'FallbackProvider') snippets = pkg_resources.EntryPoint.parse( 'snippets = spyder.plugins.completion.providers.snippets.provider:' 'SnippetsProvider') lsp = pkg_resources.EntryPoint.parse( 'lsp = spyder.plugins.completion.providers.languageserver.provider:' 'LanguageServerProvider') # Create a fake Spyder distribution d = pkg_resources.Distribution(__file__) # Add the providers to the fake EntryPoint d._ep_map = { 'spyder.completions': { 'fallback': fallback, 'snippets': snippets, 'lsp': lsp } } # Add the fake distribution to the global working_set pkg_resources.working_set.add(d, 'spyder')
def teardown(): # Remove fake entry points from pkg_resources if not running_in_ci(): pkg_resources.working_set.by_key.pop('unknown', None) pkg_resources.working_set.entry_keys.pop('spyder', None) pkg_resources.working_set.entry_keys.pop(__file__, None) pkg_resources.working_set.entries.remove('spyder')
def remove_fake_distribution(): """Remove fake entry points from pkg_resources""" # This is not necessary in CIs if running_in_ci(): return pkg_resources.working_set.by_key.pop('unknown') pkg_resources.working_set.entry_keys.pop('spyder') pkg_resources.working_set.entry_keys.pop(__file__) pkg_resources.working_set.entries.remove('spyder')
def start_server(self): """Start server.""" # This is not necessary if we're trying to connect to an # external server if self.external_server or self.stdio: return logger.info('Starting server: {0}'.format(' '.join(self.server_args))) # Create server process self.server = QProcess(self) env = self.server.processEnvironment() # Use local PyLS instead of site-packages one. if (DEV or running_under_pytest()) and not running_in_ci(): sys_path = self._clean_sys_path() env.insert('PYTHONPATH', os.pathsep.join(sys_path)[:]) # Adjustments for the Python language server. if self.language == 'python': # Set the PyLS current working to an empty dir inside # our config one. This avoids the server to pick up user # files such as random.py or string.py instead of the # standard library modules named the same. cwd = osp.join(get_conf_path(), 'lsp_paths', 'cwd') if not osp.exists(cwd): os.makedirs(cwd) # On Windows, some modules (notably Matplotlib) # cause exceptions if they cannot get the user home. # So, we need to pass the USERPROFILE env variable to # the PyLS. if os.name == "nt" and "USERPROFILE" in os.environ: env.insert("USERPROFILE", os.environ["USERPROFILE"]) else: # There's no need to define a cwd for other servers. cwd = None # Most LSP servers spawn other processes, which may require # some environment variables. for var in os.environ: env.insert(var, os.environ[var]) logger.info('Server process env variables: {0}'.format(env.keys())) # Setup server self.server.setProcessEnvironment(env) self.server.errorOccurred.connect(self.handle_process_errors) self.server.setWorkingDirectory(cwd) self.server.setProcessChannelMode(QProcess.MergedChannels) if self.server_log_file is not None: self.server.setStandardOutputFile(self.server_log_file) # Start server self.server.start(self.server_args[0], self.server_args[1:])
def add(modname, package_name, features, required_version, installed_version=None, kind=MANDATORY): """Add Spyder dependency""" global DEPENDENCIES for dependency in DEPENDENCIES: # Avoid showing an unnecessary error when running our tests. if running_in_ci() and 'spyder_boilerplate' in modname: continue if dependency.modname == modname: raise ValueError( f"Dependency has already been registered: {modname}") DEPENDENCIES += [Dependency(modname, package_name, features, required_version, installed_version, kind)]
def missing_dependencies(): """Return the status of missing dependencies (if any)""" missing_deps = [] for dependency in DEPENDENCIES: # Skip checking dependencies for which we have subrepos if (DEV or running_under_pytest()) and not running_in_ci(): repo_path = osp.normpath(osp.join(HERE, '..')) subrepos_path = osp.join(repo_path, 'external-deps') subrepos = os.listdir(subrepos_path) if dependency.package_name in subrepos: continue if dependency.kind != OPTIONAL and not dependency.check(): missing_deps.append(dependency) if missing_deps: return status(deps=missing_deps, linesep='<br>') else: return ""
def start_transport(self): """Start transport layer.""" logger.info('Starting transport for {1}: {0}'.format( ' '.join(self.transport_args), self.language)) # Create transport process self.transport = QProcess(self) env = self.transport.processEnvironment() # Most LSP servers spawn other processes other than Python, which may # require some environment variables if self.language != 'python' and self.stdio: for var in os.environ: env.insert(var, os.environ[var]) logger.info('Transport process env variables: {0}'.format( env.keys())) self.transport.setProcessEnvironment(env) # Modifying PYTHONPATH to run transport in development mode or # tests if (DEV or running_under_pytest()) and not running_in_ci(): sys_path = self._clean_sys_path() if running_under_pytest(): env.insert('PYTHONPATH', os.pathsep.join(sys_path)[:]) else: env.insert('PYTHONPATH', os.pathsep.join(sys_path)[1:]) self.transport.setProcessEnvironment(env) # Set up transport self.transport.errorOccurred.connect(self.handle_process_errors) if self.stdio: self.transport.setProcessChannelMode(QProcess.SeparateChannels) if self.transport_log_file is not None: self.transport.setStandardErrorFile(self.transport_log_file) else: self.transport.setProcessChannelMode(QProcess.MergedChannels) if self.transport_log_file is not None: self.transport.setStandardOutputFile(self.transport_log_file) # Start transport self.transport.start(self.transport_args[0], self.transport_args[1:])
def test_connection_dialog_remembers_input_with_password( qtbot, connection_dialog_factory): """ Test that the dialog remembers the user's kernel connection settings and ssh password when the user checks the save checkbox. """ dlg = connection_dialog_factory.submit_filled_dialog(use_keyfile=False, save_settings=True) # Press ok and save connection settings qtbot.mouseClick(dlg.accept_btns.button(QDialogButtonBox.Ok), Qt.LeftButton) # create new dialog and check fields new_dlg = connection_dialog_factory.get_default_dialog() assert new_dlg.cf.text() == pytest.cf_path assert new_dlg.rm_group.isChecked() assert new_dlg.hn.text() == pytest.hn assert new_dlg.un.text() == pytest.un assert new_dlg.pn.text() == str(pytest.pn) if not running_in_ci(): assert new_dlg.pw.text() == pytest.pw
import pytest # Local imports from spyder.config.base import running_in_ci from spyder.utils.vcs import (ActionToolNotFound, get_git_refs, get_git_remotes, get_git_revision, get_vcs_root, remote_to_url, run_vcs_tool) HERE = os.path.abspath(os.path.dirname(__file__)) skipnogit = pytest.mark.skipif(not (get_vcs_root(HERE)), reason="Not running from a git repo") @skipnogit @pytest.mark.skipif(running_in_ci(), reason="Not to be run outside of CIs") def test_vcs_tool(): if not os.name == 'nt': with pytest.raises(ActionToolNotFound): run_vcs_tool(osp.dirname(__file__), 'browse') else: assert run_vcs_tool(osp.dirname(__file__), 'browse') assert run_vcs_tool(osp.dirname(__file__), 'commit') @skipnogit def test_vcs_root(tmpdir): directory = tmpdir.mkdir('foo') assert get_vcs_root(str(directory)) == None assert get_vcs_root(osp.dirname(__file__)) != None
def WrappedCompletionPlugin(): # Add the fake distribution to the global working_set if not running_in_ci(): pkg_resources.working_set.add(d, 'spyder') return CompletionPlugin
# Standard library imports from unittest.mock import Mock import pkg_resources # Test library imports from qtpy.QtCore import Signal from qtpy.QtWidgets import QMainWindow import pytest # Local imports from spyder.config.base import running_in_ci from spyder.plugins.completion.plugin import CompletionPlugin from spyder.plugins.preferences.tests.conftest import config_dialog if not running_in_ci(): fallback = pkg_resources.EntryPoint.parse( 'fallback = spyder.plugins.completion.providers.fallback.provider:' 'FallbackProvider') snippets = pkg_resources.EntryPoint.parse( 'snippets = spyder.plugins.completion.providers.snippets.provider:' 'SnippetsProvider') lsp = pkg_resources.EntryPoint.parse( 'lsp = spyder.plugins.completion.providers.languageserver.provider:' 'LanguageServerProvider') # Create a fake Spyder distribution d = pkg_resources.Distribution(__file__)
""" Tests for the Spyder kernel """ import os import pytest from spyder.config.base import running_in_ci from spyder.config.manager import CONF from spyder.plugins.ipythonconsole.utils.kernelspec import SpyderKernelSpec from spyder.py3compat import PY2, is_binary_string, to_text_string from spyder.utils.encoding import to_fs_from_unicode @pytest.mark.parametrize('default_interpreter', [True, False]) @pytest.mark.skipif(not running_in_ci(), reason="Only works in CI") def test_preserve_pypath(tmpdir, default_interpreter): """ Test that PYTHONPATH is preserved in the env vars passed to the kernel when an external interpreter is used or not. Regression test for spyder-ide/spyder#8681. """ # Set default interpreter value CONF.set('main_interpreter', 'default', default_interpreter) # Add a path to PYTHONPATH env var pypath = to_text_string(tmpdir.mkdir('test-pypath')) os.environ['PYTHONPATH'] = pypath # Check that PYTHONPATH is in our kernelspec
# # Copyright © Spyder Project Contributors # Licensed under the terms of the MIT License # """Tests for pyenv.py""" import sys import time import pytest from spyder.config.base import running_in_ci from spyder.utils.pyenv import get_list_pyenv_envs, get_list_pyenv_envs_cache @pytest.mark.skipif(not running_in_ci(), reason="Only meant for CIs") @pytest.mark.skipif(not sys.platform.startswith('linux'), reason="Only runs on Linux") def test_get_list_pyenv_envs(): output = get_list_pyenv_envs() expected_envs = ['pyenv: 3.8.1'] assert set(expected_envs) == set(output.keys()) @pytest.mark.skipif(not running_in_ci(), reason="Only meant for CIs") @pytest.mark.skipif(not sys.platform.startswith('linux'), reason="Only runs on Linux") def test_get_list_pyenv_envs_cache(): time0 = time.time() output = get_list_pyenv_envs_cache() time1 = time.time()
qtbot.keyPress(code_editor, Qt.Key_Backspace, delay=300) qtbot.wait(500) assert completion.isVisible() qtbot.keyPress(code_editor, Qt.Key_Backspace, delay=300) qtbot.wait(500) assert completion.isVisible() code_editor.toggle_code_snippets(True) @pytest.mark.slow @pytest.mark.order(1) @flaky(max_runs=5) @pytest.mark.skipif(running_in_ci() and sys.platform.startswith('linux'), reason="Stalls test suite with Linux on CI") def test_automatic_completions_hide_on_save(completions_codeeditor, qtbot): """Test on-the-fly completion closing when using save shortcut (Ctrl + S). Regression test for issue #14806. """ code_editor, _ = completions_codeeditor completion = code_editor.completion_widget code_editor.toggle_code_snippets(False) code_editor.set_text('some = 0\nsomething = 1\n') cursor = code_editor.textCursor() code_editor.moveCursor(cursor.End) # Complete some -> [some, something]
"""Save a basic Python script in a file.""" name_dir = 'test dir' if not osp.exists(name_dir): os.mkdir(name_dir) os.chdir(name_dir) tmpdir.join(name_dir) script = ("with open('out.txt', 'w') as f:\n" " f.write('done')\n") scriptpath = tmpdir.join('write-done.py') scriptpath.write(script) return scriptpath # ============================================================================= # ---- Tests # ============================================================================= @pytest.mark.skipif(sys.platform.startswith('linux') or not running_in_ci(), reason='It only runs in CI services and ' 'Linux does not have pythonw executables.') def test_is_valid_w_interpreter(): assert is_python_interpreter(VALID_W_INTERPRETER) @flaky(max_runs=3) @pytest.mark.skipif(not running_in_ci(), reason='Only on CI!') def test_run_python_script_in_terminal(scriptpath, qtbot): """ Test running a Python script in an external terminal when specifying explicitly the working directory. """ # Run the script outfilepath = osp.join(scriptpath.dirname, 'out.txt')
qtbot.keyPress(completion, Qt.Key_Tab) assert "import" in [x['label'] for x in sig.args[0]] assert code_editor.toPlainText() == 'from numpy import' assert not completion.isVisible() code_editor.toggle_automatic_completions(True) code_editor.toggle_code_snippets(True) @pytest.mark.slow @pytest.mark.order(1) @flaky(max_runs=5) @pytest.mark.skipif(running_in_ci(), reason='Fails on CI!') def test_hide_widget_completion(completions_codeeditor, qtbot): """Validate hiding completion widget after a delimeter or operator.""" code_editor, _ = completions_codeeditor completion = code_editor.completion_widget delimiters = [ '(', ')', '[', ']', '{', '}', ',', ':', ';', '@', '=', '->', '+=', '-=', '*=', '/=', '//=', '%=', '@=', '&=', '|=', '^=', '>>=', '<<=', '**=' ] code_editor.toggle_automatic_completions(False) code_editor.toggle_code_snippets(False) # Set cursor to start
finder.show() finder.show_replace() qtbot.wait(100) finder.search_text.setFocus() qtbot.wait(100) assert finder.search_text.hasFocus() assert not finder.replace_text.hasFocus() qtbot.keyPress(finder.search_text, Qt.Key_Tab) qtbot.wait(100) assert not finder.search_text.hasFocus() assert finder.replace_text.hasFocus() @flaky(max_runs=3) @pytest.mark.skipif(running_in_ci(), reason="Fails on CIs") def test_tab_copies_find_to_replace(editor_find_replace_bot, qtbot): """Check that text in the find box is copied to the replace box on tab keypress. Regression test spyder-ide/spyder#4482.""" editor_stack, editor, finder = editor_find_replace_bot finder.show() finder.show_replace() finder.search_text.setFocus() finder.search_text.set_current_text('This is some test text!') qtbot.wait(500) qtbot.keyClick(finder.search_text, Qt.Key_Tab) assert finder.replace_text.currentText() == 'This is some test text!' def test_autosave_all(editor_bot, mocker): """
# set correctly. assert projects.get_active_project_path() == ppath assert projects.get_widget().treewidget.root_path == osp.dirname(ppath) assert (projects.get_widget().treewidget.rootIndex().data() == osp.basename(osp.dirname(ppath))) # Check that the first visible item in the project explorer # tree widget is the folder of the project. topleft_index = (projects.get_widget().treewidget.indexAt( projects.get_widget().treewidget.rect().topLeft())) assert topleft_index.data() == osp.basename(ppath) @flaky(max_runs=5) @pytest.mark.skipif(sys.platform == 'darwin', reason="Fails on Mac") @pytest.mark.skipif(not running_in_ci(), reason="Hangs locally sometimes") def test_filesystem_notifications(qtbot, projects, tmpdir): """ Test that filesystem notifications are emitted when creating, deleting and moving files and directories. """ # Create a directory for the project and some files. project_root = tmpdir.mkdir('project0') folder0 = project_root.mkdir('folder0') folder1 = project_root.mkdir('folder1') file0 = project_root.join('file0') file1 = folder0.join('file1') file2 = folder0.join('file2') file3 = folder1.join('file3') file0.write('') file1.write('')
from spyder.plugins.editor.widgets.tests.test_codeeditor import editorbot from spyder.utils.vcs import get_git_remotes # Constants HERE = os.path.abspath(__file__) TEST_FOLDER = os.path.abspath(os.path.dirname(__file__)) _, TEMPFILE_PATH = tempfile.mkstemp() TEST_FILES = [ os.path.join(TEST_FOLDER, f) for f in os.listdir(TEST_FOLDER) if f.endswith('.py') ] TEST_FILE_ABS = TEST_FILES[0].replace(' ', '%20') TEST_FILE_REL = 'conftest.py' @pytest.mark.skipif(running_in_ci(), reason='Fails on CI!') @pytest.mark.parametrize( 'params', [ # Parameter, expected output 1, full file path, expected output 2 # ---------------------------------------------------------------- # Files that exist with absolute paths ('file://{}\n'.format(TEMPFILE_PATH), 'file://' + TEMPFILE_PATH, TEMPFILE_PATH, 'file://' + TEMPFILE_PATH), ('"file://{}"\n'.format(TEST_FILE_ABS), 'file://' + TEST_FILE_ABS, TEST_FILE_ABS, 'file://' + TEST_FILE_ABS), # Files that exist with relative paths ('"file://./{}"\n'.format(TEST_FILE_REL), 'file://./' + TEST_FILE_REL, os.path.join(TEST_FOLDER, TEST_FILE_REL), 'file://./' + TEST_FILE_REL ), # Files that do not exist
assert CONF.get_shortcut('editor', 'redo') == 'Ctrl+Shift+Z' assert CONF.get_shortcut('editor', 'copy') == 'Ctrl+C' assert CONF.get_shortcut('editor', 'paste') == 'Ctrl+V' assert CONF.get_shortcut('editor', 'cut') == 'Ctrl+X' assert CONF.get_shortcut('editor', 'select all') == 'Ctrl+A' assert CONF.get_shortcut('editor', 'delete line') == 'Ctrl+D' assert CONF.get_shortcut('editor', 'transform to lowercase') == 'Ctrl+U' assert CONF.get_shortcut('editor', 'transform to uppercase') == 'Ctrl+Shift+U' assert CONF.get_shortcut('editor', 'go to line') == 'Ctrl+L' assert CONF.get_shortcut('editor', 'next word') == 'Ctrl+Right' assert CONF.get_shortcut('editor', 'previous word') == 'Ctrl+Left' @pytest.mark.skipif( sys.platform.startswith('linux') and running_in_ci(), reason="It fails on Linux due to the lack of a proper X server.") def test_start_and_end_of_document_shortcuts(editor_bot): """ Test that the start of document and end of document shortcut are working as expected. """ editorstack, qtbot = editor_bot editor = editorstack.get_current_editor() # Assert initial state. assert editor.get_cursor_line_column() == (0, 0) # Go to the end of the document. qtbot.keyClick(editor, Qt.Key_End, modifier=Qt.ControlModifier) assert editor.get_cursor_line_column() == (4, 0)
def find_internal_plugins(): """ Find internal plugins based on setup.py entry points. In DEV mode we parse the `setup.py` file directly. """ internal_plugins = {} # If DEV, look for entry points in setup.py file for internal plugins # and then look on the system for the rest HERE = os.path.abspath(os.path.dirname(__file__)) base_path = os.path.dirname(os.path.dirname(HERE)) setup_path = os.path.join(base_path, "setup.py") if (DEV or running_under_pytest()) and not running_in_ci(): if not os.path.isfile(setup_path): raise Exception( 'No "setup.py" file found and running in DEV mode!') with open(setup_path, "r") as fh: lines = fh.read().split("\n") start = None end = None for idx, line in enumerate(lines): if line.startswith("spyder_plugins_entry_points"): start = idx + 1 continue if start is not None: if line.startswith("]"): end = idx + 1 break entry_points_list = "[" + "\n".join(lines[start:end]) spyder_plugin_entry_points = ast.literal_eval(entry_points_list) for entry_point in spyder_plugin_entry_points: try: name, module = entry_point.split(" = ") name = name.strip() module = module.strip() module, class_name = module.split(":") except Exception: logger.error( '"setup.py" entry point "{entry_point}" is malformed!' "".format(entry_point=entry_point)) try: mod = importlib.import_module(module) internal_plugins[name] = getattr(mod, class_name, None) except (ModuleNotFoundError, ImportError) as e: raise e else: entry_points = list(pkg_resources.iter_entry_points("spyder.plugins")) internal_names = get_class_values(Plugins) for entry_point in entry_points: name = entry_point.name if name not in internal_names: continue class_name = entry_point.attrs[0] mod = importlib.import_module(entry_point.module_name) plugin_class = getattr(mod, class_name, None) internal_plugins[name] = plugin_class # FIXME: This shouldn't be necessary but it's just to be sure # plugins are sorted in alphabetical order. We need to remove it # in a later version. internal_plugins = { key: value for key, value in sorted(internal_plugins.items()) } return internal_plugins
widget.close() @flaky(max_runs=5) @pytest.mark.order(1) @pytest.mark.parametrize( "lib", [('str', 'class str', [0, 1]), ('numpy.testing', 'numpy.testing', [5, 10])] ) @pytest.mark.skipif( (sys.platform == 'darwin' or NumpyVersion(np.__version__) < NumpyVersion('1.21.0')), reason="Fails on Mac and older versions of Numpy" ) @pytest.mark.skipif( sys.platform.startswith('linux') or os.name == 'nt' and running_in_ci(), reason="Stalls CI frequenly on Linux and Windows" ) def test_get_pydoc(pydocbrowser, qtbot, lib): """ Go to the documentation by url. Regression test for spyder-ide/spyder#10740 """ browser = pydocbrowser element, doc, matches = lib webview = browser.webview element_url = browser.text_to_url(element) with qtbot.waitSignal(webview.loadFinished): browser.set_url(element_url)
def env(self): """Env vars for kernels""" default_interpreter = self.get_conf('default', section='main_interpreter') env_vars = os.environ.copy() # Avoid IPython adding the virtualenv on which Spyder is running # to the kernel sys.path env_vars.pop('VIRTUAL_ENV', None) # Add spyder-kernels subrepo path to PYTHONPATH if (DEV or running_under_pytest()) and not running_in_ci(): repo_path = osp.normpath(osp.join(HERE, '..', '..', '..', '..')) subrepo_path = osp.join(repo_path, 'external-deps', 'spyder-kernels') env_vars.update({'PYTHONPATH': subrepo_path}) # List of paths declared by the user, plus project's path, to # add to PYTHONPATH pathlist = self.get_conf('spyder_pythonpath', default=[], section='main') pypath = os.pathsep.join(pathlist) # List of modules to exclude from our UMR umr_namelist = self.get_conf('umr/namelist', section='main_interpreter') # Environment variables that we need to pass to the kernel env_vars.update({ 'SPY_EXTERNAL_INTERPRETER': not default_interpreter, 'SPY_UMR_ENABLED': self.get_conf('umr/enabled', section='main_interpreter'), 'SPY_UMR_VERBOSE': self.get_conf('umr/verbose', section='main_interpreter'), 'SPY_UMR_NAMELIST': ','.join(umr_namelist), 'SPY_RUN_LINES_O': self.get_conf('startup/run_lines'), 'SPY_PYLAB_O': self.get_conf('pylab'), 'SPY_BACKEND_O': self.get_conf('pylab/backend'), 'SPY_AUTOLOAD_PYLAB_O': self.get_conf('pylab/autoload'), 'SPY_FORMAT_O': self.get_conf('pylab/inline/figure_format'), 'SPY_BBOX_INCHES_O': self.get_conf('pylab/inline/bbox_inches'), 'SPY_RESOLUTION_O': self.get_conf('pylab/inline/resolution'), 'SPY_WIDTH_O': self.get_conf('pylab/inline/width'), 'SPY_HEIGHT_O': self.get_conf('pylab/inline/height'), 'SPY_USE_FILE_O': self.get_conf('startup/use_run_file'), 'SPY_RUN_FILE_O': self.get_conf('startup/run_file'), 'SPY_AUTOCALL_O': self.get_conf('autocall'), 'SPY_GREEDY_O': self.get_conf('greedy_completer'), 'SPY_JEDI_O': self.get_conf('jedi_completer'), 'SPY_SYMPY_O': self.get_conf('symbolic_math'), 'SPY_TESTING': running_under_pytest() or get_safe_mode(), 'SPY_HIDE_CMD': self.get_conf('hide_cmd_windows'), 'SPY_PYTHONPATH': pypath }) if self.is_pylab is True: env_vars['SPY_AUTOLOAD_PYLAB_O'] = True env_vars['SPY_SYMPY_O'] = False env_vars['SPY_RUN_CYTHON'] = False if self.is_sympy is True: env_vars['SPY_AUTOLOAD_PYLAB_O'] = False env_vars['SPY_SYMPY_O'] = True env_vars['SPY_RUN_CYTHON'] = False if self.is_cython is True: env_vars['SPY_AUTOLOAD_PYLAB_O'] = False env_vars['SPY_SYMPY_O'] = False env_vars['SPY_RUN_CYTHON'] = True # App considerations if (running_in_mac_app() or is_pynsist()) and not default_interpreter: env_vars.pop('PYTHONHOME', None) env_vars.pop('PYTHONPATH', None) # Remove this variable because it prevents starting kernels for # external interpreters when present. # Fixes spyder-ide/spyder#13252 env_vars.pop('PYTHONEXECUTABLE', None) # Making all env_vars strings clean_env_vars = clean_env(env_vars) return clean_env_vars
qtbot.keyPress(completion, Qt.Key_Tab) assert "import" in [x['label'] for x in sig.args[0]] assert code_editor.toPlainText() == 'from numpy import' assert not completion.isVisible() code_editor.toggle_automatic_completions(True) code_editor.toggle_code_snippets(True) @pytest.mark.slow @pytest.mark.order(1) @flaky(max_runs=5) @pytest.mark.skipif(running_in_ci(), reason='Fails on CI!') def test_hide_widget_completion(completions_codeeditor, qtbot): """Validate hiding completion widget after a delimeter or operator.""" code_editor, _ = completions_codeeditor completion = code_editor.completion_widget delimiters = ['(', ')', '[', ']', '{', '}', ',', ':', ';', '@', '=', '->', '+=', '-=', '*=', '/=', '//=', '%=', '@=', '&=', '|=', '^=', '>>=', '<<=', '**='] code_editor.toggle_automatic_completions(False) code_editor.toggle_code_snippets(False) # Set cursor to start code_editor.set_text('') code_editor.completion_widget.hide()
ret_value = b.send_report('Empty credentials', 'Wrong credentials') assert ret_value is False def test_fake_credentials_bad_repo(): b = get_backend_bad_repo() b.get_user_credentials = get_fake_user_credentials ret_value = b.send_report('Test suite', 'Test fake credentials') assert ret_value is False def test_get_credentials_from_settings(): b = get_backend() remember_token = b._get_credentials_from_settings() assert remember_token is False CONF.set('main', 'report_error/remember_token', True) remember_token = b._get_credentials_from_settings() assert remember_token is True @pytest.mark.skipif(running_in_ci(), reason="Only works locally") def test_store_user_credentials(): b = get_backend() b._store_token('token', True) credentials = b.get_user_credentials() assert credentials['token'] == 'token' assert credentials['remember_token'] is True