code
stringlengths
9
189k
meta_data.file_name
stringclasses
538 values
meta_data.module
stringclasses
202 values
meta_data.contains_class
bool
2 classes
meta_data.contains_function
bool
2 classes
meta_data.file_imports
sequencelengths
0
97
meta_data.start_line
int64
-1
6.71k
meta_data.end_line
int64
-1
6.74k
def closeEvent(self, event): """closeEvent reimplementation""" if self.closing(True): event.accept() else: event.ignore() def resizeEvent(self, event): """Reimplement Qt method""" if not self.isMaximized() and not self.layouts.get_fullscreen_flag(): self.window_size = self.size() QMainWindow.resizeEvent(self, event) # To be used by the tour to be able to resize self.sig_resized.emit(event) def moveEvent(self, event): """Reimplement Qt method""" if hasattr(self, 'layouts') and self.layouts is not None: if ( not self.isMaximized() and not self.layouts.get_fullscreen_flag() ): self.window_position = self.pos() QMainWindow.moveEvent(self, event) # To be used by the tour to be able to move self.sig_moved.emit(event)
mainwindow.py
spyder.spyder.app
false
true
[ "from collections import OrderedDict", "import configparser as cp", "from enum import Enum", "import errno", "import gc", "import logging", "import os", "import os.path as osp", "import shutil", "import signal", "import socket", "import sys", "import threading", "import traceback", "from spyder import requirements", "from qtpy.QtCore import (QCoreApplication, Qt, QTimer, Signal, Slot,", "from qtpy.QtGui import QColor, QKeySequence", "from qtpy.QtWidgets import QApplication, QMainWindow, QMessageBox, QShortcut", "from qtpy import QtSvg # analysis:ignore", "from qtpy import QtWebEngineWidgets # analysis:ignore", "from qtawesome.iconic_font import FontError", "from spyder import __version__", "from spyder.app.find_plugins import (", "from spyder.app.utils import (", "from spyder.api.plugin_registration.registry import PLUGIN_REGISTRY", "from spyder.api.config.mixins import SpyderConfigurationAccessor", "from spyder.api.widgets.mixins import SpyderMainWindowMixin", "from spyder.config.base import (_, DEV, get_conf_path, get_debug_level,", "from spyder.config.gui import is_dark_font_color", "from spyder.config.main import OPEN_FILES_PORT", "from spyder.config.manager import CONF", "from spyder.config.utils import IMPORT_EXT", "from spyder.py3compat import to_text_string", "from spyder.utils import encoding, programs", "from spyder.utils.icon_manager import ima", "from spyder.utils.misc import select_port, getcwd_or_home", "from spyder.utils.palette import QStylePalette", "from spyder.utils.qthelpers import file_uri, qapplication, start_file", "from spyder.utils.stylesheet import APP_STYLESHEET", "from spyder.api.exceptions import SpyderAPIError", "from spyder.api.plugins import (", "from spyder.utils.windows import (set_attached_console_visible,", "from spyder.utils.qthelpers import SpyderProxyStyle", "import win32api", "from spyder.plugins.help.utils.sphinxify import CSS_PATH, DARK_CSS_PATH", "import spyder", "import faulthandler" ]
1,051
1,077
def hideEvent(self, event): """Reimplement Qt method""" try: for plugin in (self.widgetlist + self.thirdparty_plugins): # TODO: Remove old API try: # New API if plugin.get_widget().isAncestorOf( self.last_focused_widget): plugin.change_visibility(True) except AttributeError: # Old API if plugin.isAncestorOf(self.last_focused_widget): plugin._visibility_changed(True) QMainWindow.hideEvent(self, event) except RuntimeError: QMainWindow.hideEvent(self, event) # ---- Other # ------------------------------------------------------------------------- def free_memory(self): """Free memory after event.""" gc.collect() def set_splash(self, message): """Set splash message""" if self.splash is None: return if message: logger.info(message) self.splash.show() self.splash.showMessage(message, int(Qt.AlignBottom | Qt.AlignCenter | Qt.AlignAbsolute), QColor(Qt.white)) QApplication.processEvents()
mainwindow.py
spyder.spyder.app
false
true
[ "from collections import OrderedDict", "import configparser as cp", "from enum import Enum", "import errno", "import gc", "import logging", "import os", "import os.path as osp", "import shutil", "import signal", "import socket", "import sys", "import threading", "import traceback", "from spyder import requirements", "from qtpy.QtCore import (QCoreApplication, Qt, QTimer, Signal, Slot,", "from qtpy.QtGui import QColor, QKeySequence", "from qtpy.QtWidgets import QApplication, QMainWindow, QMessageBox, QShortcut", "from qtpy import QtSvg # analysis:ignore", "from qtpy import QtWebEngineWidgets # analysis:ignore", "from qtawesome.iconic_font import FontError", "from spyder import __version__", "from spyder.app.find_plugins import (", "from spyder.app.utils import (", "from spyder.api.plugin_registration.registry import PLUGIN_REGISTRY", "from spyder.api.config.mixins import SpyderConfigurationAccessor", "from spyder.api.widgets.mixins import SpyderMainWindowMixin", "from spyder.config.base import (_, DEV, get_conf_path, get_debug_level,", "from spyder.config.gui import is_dark_font_color", "from spyder.config.main import OPEN_FILES_PORT", "from spyder.config.manager import CONF", "from spyder.config.utils import IMPORT_EXT", "from spyder.py3compat import to_text_string", "from spyder.utils import encoding, programs", "from spyder.utils.icon_manager import ima", "from spyder.utils.misc import select_port, getcwd_or_home", "from spyder.utils.palette import QStylePalette", "from spyder.utils.qthelpers import file_uri, qapplication, start_file", "from spyder.utils.stylesheet import APP_STYLESHEET", "from spyder.api.exceptions import SpyderAPIError", "from spyder.api.plugins import (", "from spyder.utils.windows import (set_attached_console_visible,", "from spyder.utils.qthelpers import SpyderProxyStyle", "import win32api", "from spyder.plugins.help.utils.sphinxify import CSS_PATH, DARK_CSS_PATH", "import spyder", "import faulthandler" ]
1,079
1,115
def change_last_focused_widget(self, old, now): """To keep track of to the last focused widget""" if (now is None and QApplication.activeWindow() is not None): QApplication.activeWindow().setFocus() self.last_focused_widget = QApplication.focusWidget() elif now is not None: self.last_focused_widget = now self.previous_focused_widget = old def closing(self, cancelable=False, close_immediately=False): """Exit tasks""" if self.already_closed or self.is_starting_up: return True self.layouts.save_visible_plugins() self.plugin_registry = PLUGIN_REGISTRY if cancelable and self.get_conf('prompt_on_exit'): reply = QMessageBox.critical(self, 'Spyder', 'Do you really want to exit?', QMessageBox.Yes, QMessageBox.No) if reply == QMessageBox.No: return False can_close = self.plugin_registry.delete_all_plugins( excluding={Plugins.Layout}, close_immediately=close_immediately) if not can_close and not close_immediately: return False
mainwindow.py
spyder.spyder.app
false
true
[ "from collections import OrderedDict", "import configparser as cp", "from enum import Enum", "import errno", "import gc", "import logging", "import os", "import os.path as osp", "import shutil", "import signal", "import socket", "import sys", "import threading", "import traceback", "from spyder import requirements", "from qtpy.QtCore import (QCoreApplication, Qt, QTimer, Signal, Slot,", "from qtpy.QtGui import QColor, QKeySequence", "from qtpy.QtWidgets import QApplication, QMainWindow, QMessageBox, QShortcut", "from qtpy import QtSvg # analysis:ignore", "from qtpy import QtWebEngineWidgets # analysis:ignore", "from qtawesome.iconic_font import FontError", "from spyder import __version__", "from spyder.app.find_plugins import (", "from spyder.app.utils import (", "from spyder.api.plugin_registration.registry import PLUGIN_REGISTRY", "from spyder.api.config.mixins import SpyderConfigurationAccessor", "from spyder.api.widgets.mixins import SpyderMainWindowMixin", "from spyder.config.base import (_, DEV, get_conf_path, get_debug_level,", "from spyder.config.gui import is_dark_font_color", "from spyder.config.main import OPEN_FILES_PORT", "from spyder.config.manager import CONF", "from spyder.config.utils import IMPORT_EXT", "from spyder.py3compat import to_text_string", "from spyder.utils import encoding, programs", "from spyder.utils.icon_manager import ima", "from spyder.utils.misc import select_port, getcwd_or_home", "from spyder.utils.palette import QStylePalette", "from spyder.utils.qthelpers import file_uri, qapplication, start_file", "from spyder.utils.stylesheet import APP_STYLESHEET", "from spyder.api.exceptions import SpyderAPIError", "from spyder.api.plugins import (", "from spyder.utils.windows import (set_attached_console_visible,", "from spyder.utils.qthelpers import SpyderProxyStyle", "import win32api", "from spyder.plugins.help.utils.sphinxify import CSS_PATH, DARK_CSS_PATH", "import spyder", "import faulthandler" ]
1,117
1,148
if not can_close and not close_immediately: return False # Save window settings *after* closing all plugin windows, in order # to show them in their previous locations in the next session. # Fixes spyder-ide/spyder#12139 prefix = 'window' + '/' if self.layouts is not None: self.layouts.save_current_window_settings(prefix) try: layouts_container = self.layouts.get_container() if layouts_container: layouts_container.close() layouts_container.deleteLater() self.layouts.deleteLater() self.plugin_registry.delete_plugin( Plugins.Layout, teardown=False) except RuntimeError: pass self.already_closed = True if self.get_conf('single_instance') and self.open_files_server: self.open_files_server.close() QApplication.processEvents() return True
mainwindow.py
spyder.spyder.app
false
false
[ "from collections import OrderedDict", "import configparser as cp", "from enum import Enum", "import errno", "import gc", "import logging", "import os", "import os.path as osp", "import shutil", "import signal", "import socket", "import sys", "import threading", "import traceback", "from spyder import requirements", "from qtpy.QtCore import (QCoreApplication, Qt, QTimer, Signal, Slot,", "from qtpy.QtGui import QColor, QKeySequence", "from qtpy.QtWidgets import QApplication, QMainWindow, QMessageBox, QShortcut", "from qtpy import QtSvg # analysis:ignore", "from qtpy import QtWebEngineWidgets # analysis:ignore", "from qtawesome.iconic_font import FontError", "from spyder import __version__", "from spyder.app.find_plugins import (", "from spyder.app.utils import (", "from spyder.api.plugin_registration.registry import PLUGIN_REGISTRY", "from spyder.api.config.mixins import SpyderConfigurationAccessor", "from spyder.api.widgets.mixins import SpyderMainWindowMixin", "from spyder.config.base import (_, DEV, get_conf_path, get_debug_level,", "from spyder.config.gui import is_dark_font_color", "from spyder.config.main import OPEN_FILES_PORT", "from spyder.config.manager import CONF", "from spyder.config.utils import IMPORT_EXT", "from spyder.py3compat import to_text_string", "from spyder.utils import encoding, programs", "from spyder.utils.icon_manager import ima", "from spyder.utils.misc import select_port, getcwd_or_home", "from spyder.utils.palette import QStylePalette", "from spyder.utils.qthelpers import file_uri, qapplication, start_file", "from spyder.utils.stylesheet import APP_STYLESHEET", "from spyder.api.exceptions import SpyderAPIError", "from spyder.api.plugins import (", "from spyder.utils.windows import (set_attached_console_visible,", "from spyder.utils.qthelpers import SpyderProxyStyle", "import win32api", "from spyder.plugins.help.utils.sphinxify import CSS_PATH, DARK_CSS_PATH", "import spyder", "import faulthandler" ]
1,147
1,174
if self.get_conf('single_instance') and self.open_files_server: self.open_files_server.close() QApplication.processEvents() return True def add_dockwidget(self, plugin): """ Add a plugin QDockWidget to the main window. """ try: # New API if plugin.is_compatible: dockwidget, location = plugin.create_dockwidget(self) self.addDockWidget(location, dockwidget) self.widgetlist.append(plugin) except AttributeError: # Old API if plugin._is_compatible: dockwidget, location = plugin._create_dockwidget() self.addDockWidget(location, dockwidget) self.widgetlist.append(plugin) def redirect_internalshell_stdio(self, state): console = self.get_plugin(Plugins.Console, error=False) if console: if state: console.redirect_stds() else: console.restore_stds()
mainwindow.py
spyder.spyder.app
false
true
[ "from collections import OrderedDict", "import configparser as cp", "from enum import Enum", "import errno", "import gc", "import logging", "import os", "import os.path as osp", "import shutil", "import signal", "import socket", "import sys", "import threading", "import traceback", "from spyder import requirements", "from qtpy.QtCore import (QCoreApplication, Qt, QTimer, Signal, Slot,", "from qtpy.QtGui import QColor, QKeySequence", "from qtpy.QtWidgets import QApplication, QMainWindow, QMessageBox, QShortcut", "from qtpy import QtSvg # analysis:ignore", "from qtpy import QtWebEngineWidgets # analysis:ignore", "from qtawesome.iconic_font import FontError", "from spyder import __version__", "from spyder.app.find_plugins import (", "from spyder.app.utils import (", "from spyder.api.plugin_registration.registry import PLUGIN_REGISTRY", "from spyder.api.config.mixins import SpyderConfigurationAccessor", "from spyder.api.widgets.mixins import SpyderMainWindowMixin", "from spyder.config.base import (_, DEV, get_conf_path, get_debug_level,", "from spyder.config.gui import is_dark_font_color", "from spyder.config.main import OPEN_FILES_PORT", "from spyder.config.manager import CONF", "from spyder.config.utils import IMPORT_EXT", "from spyder.py3compat import to_text_string", "from spyder.utils import encoding, programs", "from spyder.utils.icon_manager import ima", "from spyder.utils.misc import select_port, getcwd_or_home", "from spyder.utils.palette import QStylePalette", "from spyder.utils.qthelpers import file_uri, qapplication, start_file", "from spyder.utils.stylesheet import APP_STYLESHEET", "from spyder.api.exceptions import SpyderAPIError", "from spyder.api.plugins import (", "from spyder.utils.windows import (set_attached_console_visible,", "from spyder.utils.qthelpers import SpyderProxyStyle", "import win32api", "from spyder.plugins.help.utils.sphinxify import CSS_PATH, DARK_CSS_PATH", "import spyder", "import faulthandler" ]
1,169
1,199
def open_file(self, fname, external=False): """ Open filename with the appropriate application Redirect to the right widget (txt -> editor, spydata -> workspace, ...) or open file outside Spyder (if extension is not supported) """ fname = to_text_string(fname) ext = osp.splitext(fname)[1] editor = self.get_plugin(Plugins.Editor, error=False) variableexplorer = self.get_plugin( Plugins.VariableExplorer, error=False) if encoding.is_text_file(fname): if editor: editor.load(fname) elif variableexplorer is not None and ext in IMPORT_EXT: variableexplorer.get_widget().import_data(fname) elif not external: fname = file_uri(fname) start_file(fname) def get_initial_working_directory(self): """Return the initial working directory.""" return self.INITIAL_CWD def open_external_file(self, fname): """ Open external files that can be handled either by the Editor or the variable explorer inside Spyder. """ # Check that file exists fname = encoding.to_unicode_from_fs(fname) initial_cwd = self.get_initial_working_directory() if osp.exists(osp.join(initial_cwd, fname)): fpath = osp.join(initial_cwd, fname) elif osp.exists(fname): fpath = fname else: return
mainwindow.py
spyder.spyder.app
false
true
[ "from collections import OrderedDict", "import configparser as cp", "from enum import Enum", "import errno", "import gc", "import logging", "import os", "import os.path as osp", "import shutil", "import signal", "import socket", "import sys", "import threading", "import traceback", "from spyder import requirements", "from qtpy.QtCore import (QCoreApplication, Qt, QTimer, Signal, Slot,", "from qtpy.QtGui import QColor, QKeySequence", "from qtpy.QtWidgets import QApplication, QMainWindow, QMessageBox, QShortcut", "from qtpy import QtSvg # analysis:ignore", "from qtpy import QtWebEngineWidgets # analysis:ignore", "from qtawesome.iconic_font import FontError", "from spyder import __version__", "from spyder.app.find_plugins import (", "from spyder.app.utils import (", "from spyder.api.plugin_registration.registry import PLUGIN_REGISTRY", "from spyder.api.config.mixins import SpyderConfigurationAccessor", "from spyder.api.widgets.mixins import SpyderMainWindowMixin", "from spyder.config.base import (_, DEV, get_conf_path, get_debug_level,", "from spyder.config.gui import is_dark_font_color", "from spyder.config.main import OPEN_FILES_PORT", "from spyder.config.manager import CONF", "from spyder.config.utils import IMPORT_EXT", "from spyder.py3compat import to_text_string", "from spyder.utils import encoding, programs", "from spyder.utils.icon_manager import ima", "from spyder.utils.misc import select_port, getcwd_or_home", "from spyder.utils.palette import QStylePalette", "from spyder.utils.qthelpers import file_uri, qapplication, start_file", "from spyder.utils.stylesheet import APP_STYLESHEET", "from spyder.api.exceptions import SpyderAPIError", "from spyder.api.plugins import (", "from spyder.utils.windows import (set_attached_console_visible,", "from spyder.utils.qthelpers import SpyderProxyStyle", "import win32api", "from spyder.plugins.help.utils.sphinxify import CSS_PATH, DARK_CSS_PATH", "import spyder", "import faulthandler" ]
1,201
1,239
# Don't open script that starts Spyder at startup. # Fixes issue spyder-ide/spyder#14483 if sys.platform == 'darwin' and 'bin/spyder' in fname: return if osp.isfile(fpath): self.open_file(fpath, external=True) elif osp.isdir(fpath): QMessageBox.warning( self, _("Error"), _('To open <code>{fpath}</code> as a project with Spyder, ' 'please use <code>spyder -p "{fname}"</code>.') .format(fpath=osp.normpath(fpath), fname=fname) ) # ---- Preferences # ------------------------------------------------------------------------- def apply_settings(self): """Apply main window settings.""" qapp = QApplication.instance() self.apply_panes_settings() if self.get_conf('use_custom_cursor_blinking'): qapp.setCursorFlashTime( self.get_conf('custom_cursor_blinking')) else: qapp.setCursorFlashTime(self.CURSORBLINK_OSDEFAULT) def apply_panes_settings(self): """Update dockwidgets features settings.""" for plugin in (self.widgetlist + self.thirdparty_plugins): features = plugin.dockwidget.FEATURES plugin.dockwidget.setFeatures(features)
mainwindow.py
spyder.spyder.app
false
true
[ "from collections import OrderedDict", "import configparser as cp", "from enum import Enum", "import errno", "import gc", "import logging", "import os", "import os.path as osp", "import shutil", "import signal", "import socket", "import sys", "import threading", "import traceback", "from spyder import requirements", "from qtpy.QtCore import (QCoreApplication, Qt, QTimer, Signal, Slot,", "from qtpy.QtGui import QColor, QKeySequence", "from qtpy.QtWidgets import QApplication, QMainWindow, QMessageBox, QShortcut", "from qtpy import QtSvg # analysis:ignore", "from qtpy import QtWebEngineWidgets # analysis:ignore", "from qtawesome.iconic_font import FontError", "from spyder import __version__", "from spyder.app.find_plugins import (", "from spyder.app.utils import (", "from spyder.api.plugin_registration.registry import PLUGIN_REGISTRY", "from spyder.api.config.mixins import SpyderConfigurationAccessor", "from spyder.api.widgets.mixins import SpyderMainWindowMixin", "from spyder.config.base import (_, DEV, get_conf_path, get_debug_level,", "from spyder.config.gui import is_dark_font_color", "from spyder.config.main import OPEN_FILES_PORT", "from spyder.config.manager import CONF", "from spyder.config.utils import IMPORT_EXT", "from spyder.py3compat import to_text_string", "from spyder.utils import encoding, programs", "from spyder.utils.icon_manager import ima", "from spyder.utils.misc import select_port, getcwd_or_home", "from spyder.utils.palette import QStylePalette", "from spyder.utils.qthelpers import file_uri, qapplication, start_file", "from spyder.utils.stylesheet import APP_STYLESHEET", "from spyder.api.exceptions import SpyderAPIError", "from spyder.api.plugins import (", "from spyder.utils.windows import (set_attached_console_visible,", "from spyder.utils.qthelpers import SpyderProxyStyle", "import win32api", "from spyder.plugins.help.utils.sphinxify import CSS_PATH, DARK_CSS_PATH", "import spyder", "import faulthandler" ]
1,241
1,274
plugin.dockwidget.setFeatures(features) try: # New API margin = 0 if self.get_conf('use_custom_margin'): margin = self.get_conf('custom_margin') plugin.update_margins(margin) except AttributeError: # Old API plugin._update_margins() @Slot() def show_preferences(self): """Edit Spyder preferences.""" self.preferences.open_dialog() # ---- Open files server # ------------------------------------------------------------------------- def start_open_files_server(self): self.open_files_server.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR, 1) port = select_port(default_port=OPEN_FILES_PORT) self.set_conf('open_files_port', port) # This is necessary in case it's not possible to bind a port for the # server in the system. # Fixes spyder-ide/spyder#18262 try: self.open_files_server.bind(('127.0.0.1', port)) except OSError: self.open_files_server = None return # Number of petitions the server can queue self.open_files_server.listen(20)
mainwindow.py
spyder.spyder.app
false
true
[ "from collections import OrderedDict", "import configparser as cp", "from enum import Enum", "import errno", "import gc", "import logging", "import os", "import os.path as osp", "import shutil", "import signal", "import socket", "import sys", "import threading", "import traceback", "from spyder import requirements", "from qtpy.QtCore import (QCoreApplication, Qt, QTimer, Signal, Slot,", "from qtpy.QtGui import QColor, QKeySequence", "from qtpy.QtWidgets import QApplication, QMainWindow, QMessageBox, QShortcut", "from qtpy import QtSvg # analysis:ignore", "from qtpy import QtWebEngineWidgets # analysis:ignore", "from qtawesome.iconic_font import FontError", "from spyder import __version__", "from spyder.app.find_plugins import (", "from spyder.app.utils import (", "from spyder.api.plugin_registration.registry import PLUGIN_REGISTRY", "from spyder.api.config.mixins import SpyderConfigurationAccessor", "from spyder.api.widgets.mixins import SpyderMainWindowMixin", "from spyder.config.base import (_, DEV, get_conf_path, get_debug_level,", "from spyder.config.gui import is_dark_font_color", "from spyder.config.main import OPEN_FILES_PORT", "from spyder.config.manager import CONF", "from spyder.config.utils import IMPORT_EXT", "from spyder.py3compat import to_text_string", "from spyder.utils import encoding, programs", "from spyder.utils.icon_manager import ima", "from spyder.utils.misc import select_port, getcwd_or_home", "from spyder.utils.palette import QStylePalette", "from spyder.utils.qthelpers import file_uri, qapplication, start_file", "from spyder.utils.stylesheet import APP_STYLESHEET", "from spyder.api.exceptions import SpyderAPIError", "from spyder.api.plugins import (", "from spyder.utils.windows import (set_attached_console_visible,", "from spyder.utils.qthelpers import SpyderProxyStyle", "import win32api", "from spyder.plugins.help.utils.sphinxify import CSS_PATH, DARK_CSS_PATH", "import spyder", "import faulthandler" ]
1,274
1,309
# Number of petitions the server can queue self.open_files_server.listen(20) while 1: # 1 is faster than True try: req, dummy = self.open_files_server.accept() except socket.error as e: # See spyder-ide/spyder#1275 for details on why errno EINTR is # silently ignored here. eintr = errno.WSAEINTR if os.name == 'nt' else errno.EINTR # To avoid a traceback after closing on Windows if e.args[0] == eintr: continue # handle a connection abort on close error enotsock = (errno.WSAENOTSOCK if os.name == 'nt' else errno.ENOTSOCK) if e.args[0] in [errno.ECONNABORTED, enotsock]: return if self.already_closed: return raise fname = req.recv(1024) fname = fname.decode('utf-8') self.sig_open_external_file.emit(fname) req.sendall(b' ') # ---- Restart Spyder # ------------------------------------------------------------------------- def restart(self, reset=False, close_immediately=False): """Wrapper to handle plugins request to restart Spyder.""" self.application.restart( reset=reset, close_immediately=close_immediately)
mainwindow.py
spyder.spyder.app
false
true
[ "from collections import OrderedDict", "import configparser as cp", "from enum import Enum", "import errno", "import gc", "import logging", "import os", "import os.path as osp", "import shutil", "import signal", "import socket", "import sys", "import threading", "import traceback", "from spyder import requirements", "from qtpy.QtCore import (QCoreApplication, Qt, QTimer, Signal, Slot,", "from qtpy.QtGui import QColor, QKeySequence", "from qtpy.QtWidgets import QApplication, QMainWindow, QMessageBox, QShortcut", "from qtpy import QtSvg # analysis:ignore", "from qtpy import QtWebEngineWidgets # analysis:ignore", "from qtawesome.iconic_font import FontError", "from spyder import __version__", "from spyder.app.find_plugins import (", "from spyder.app.utils import (", "from spyder.api.plugin_registration.registry import PLUGIN_REGISTRY", "from spyder.api.config.mixins import SpyderConfigurationAccessor", "from spyder.api.widgets.mixins import SpyderMainWindowMixin", "from spyder.config.base import (_, DEV, get_conf_path, get_debug_level,", "from spyder.config.gui import is_dark_font_color", "from spyder.config.main import OPEN_FILES_PORT", "from spyder.config.manager import CONF", "from spyder.config.utils import IMPORT_EXT", "from spyder.py3compat import to_text_string", "from spyder.utils import encoding, programs", "from spyder.utils.icon_manager import ima", "from spyder.utils.misc import select_port, getcwd_or_home", "from spyder.utils.palette import QStylePalette", "from spyder.utils.qthelpers import file_uri, qapplication, start_file", "from spyder.utils.stylesheet import APP_STYLESHEET", "from spyder.api.exceptions import SpyderAPIError", "from spyder.api.plugins import (", "from spyder.utils.windows import (set_attached_console_visible,", "from spyder.utils.qthelpers import SpyderProxyStyle", "import win32api", "from spyder.plugins.help.utils.sphinxify import CSS_PATH, DARK_CSS_PATH", "import spyder", "import faulthandler" ]
1,308
1,339
# --- For OpenGL def _test_setting_opengl(self, option): """Get the current OpenGL implementation in use""" if option == 'software': return QCoreApplication.testAttribute(Qt.AA_UseSoftwareOpenGL) elif option == 'desktop': return QCoreApplication.testAttribute(Qt.AA_UseDesktopOpenGL) elif option == 'gles': return QCoreApplication.testAttribute(Qt.AA_UseOpenGLES)
mainwindow.py
spyder.spyder.app
false
true
[ "from collections import OrderedDict", "import configparser as cp", "from enum import Enum", "import errno", "import gc", "import logging", "import os", "import os.path as osp", "import shutil", "import signal", "import socket", "import sys", "import threading", "import traceback", "from spyder import requirements", "from qtpy.QtCore import (QCoreApplication, Qt, QTimer, Signal, Slot,", "from qtpy.QtGui import QColor, QKeySequence", "from qtpy.QtWidgets import QApplication, QMainWindow, QMessageBox, QShortcut", "from qtpy import QtSvg # analysis:ignore", "from qtpy import QtWebEngineWidgets # analysis:ignore", "from qtawesome.iconic_font import FontError", "from spyder import __version__", "from spyder.app.find_plugins import (", "from spyder.app.utils import (", "from spyder.api.plugin_registration.registry import PLUGIN_REGISTRY", "from spyder.api.config.mixins import SpyderConfigurationAccessor", "from spyder.api.widgets.mixins import SpyderMainWindowMixin", "from spyder.config.base import (_, DEV, get_conf_path, get_debug_level,", "from spyder.config.gui import is_dark_font_color", "from spyder.config.main import OPEN_FILES_PORT", "from spyder.config.manager import CONF", "from spyder.config.utils import IMPORT_EXT", "from spyder.py3compat import to_text_string", "from spyder.utils import encoding, programs", "from spyder.utils.icon_manager import ima", "from spyder.utils.misc import select_port, getcwd_or_home", "from spyder.utils.palette import QStylePalette", "from spyder.utils.qthelpers import file_uri, qapplication, start_file", "from spyder.utils.stylesheet import APP_STYLESHEET", "from spyder.api.exceptions import SpyderAPIError", "from spyder.api.plugins import (", "from spyder.utils.windows import (set_attached_console_visible,", "from spyder.utils.qthelpers import SpyderProxyStyle", "import win32api", "from spyder.plugins.help.utils.sphinxify import CSS_PATH, DARK_CSS_PATH", "import spyder", "import faulthandler" ]
1,341
1,349
def main(options, args): """Main function""" # **** For Pytest **** if running_under_pytest(): if CONF.get('main', 'opengl') != 'automatic': option = CONF.get('main', 'opengl') set_opengl_implementation(option) app = create_application() window = create_window(MainWindow, app, None, options, None) return window # **** Handle hide_console option **** if options.show_console: print("(Deprecated) --show console does nothing, now the default " " behavior is to show the console, use --hide-console if you " "want to hide it") if set_attached_console_visible is not None: set_attached_console_visible(not options.hide_console or options.reset_config_files or options.reset_to_defaults or options.optimize or bool(get_debug_level())) # **** Set OpenGL implementation to use **** # This attribute must be set before creating the application. # See spyder-ide/spyder#11227 if options.opengl_implementation: option = options.opengl_implementation set_opengl_implementation(option) else: if CONF.get('main', 'opengl') != 'automatic': option = CONF.get('main', 'opengl') set_opengl_implementation(option)
mainwindow.py
spyder.spyder.app
false
true
[ "from collections import OrderedDict", "import configparser as cp", "from enum import Enum", "import errno", "import gc", "import logging", "import os", "import os.path as osp", "import shutil", "import signal", "import socket", "import sys", "import threading", "import traceback", "from spyder import requirements", "from qtpy.QtCore import (QCoreApplication, Qt, QTimer, Signal, Slot,", "from qtpy.QtGui import QColor, QKeySequence", "from qtpy.QtWidgets import QApplication, QMainWindow, QMessageBox, QShortcut", "from qtpy import QtSvg # analysis:ignore", "from qtpy import QtWebEngineWidgets # analysis:ignore", "from qtawesome.iconic_font import FontError", "from spyder import __version__", "from spyder.app.find_plugins import (", "from spyder.app.utils import (", "from spyder.api.plugin_registration.registry import PLUGIN_REGISTRY", "from spyder.api.config.mixins import SpyderConfigurationAccessor", "from spyder.api.widgets.mixins import SpyderMainWindowMixin", "from spyder.config.base import (_, DEV, get_conf_path, get_debug_level,", "from spyder.config.gui import is_dark_font_color", "from spyder.config.main import OPEN_FILES_PORT", "from spyder.config.manager import CONF", "from spyder.config.utils import IMPORT_EXT", "from spyder.py3compat import to_text_string", "from spyder.utils import encoding, programs", "from spyder.utils.icon_manager import ima", "from spyder.utils.misc import select_port, getcwd_or_home", "from spyder.utils.palette import QStylePalette", "from spyder.utils.qthelpers import file_uri, qapplication, start_file", "from spyder.utils.stylesheet import APP_STYLESHEET", "from spyder.api.exceptions import SpyderAPIError", "from spyder.api.plugins import (", "from spyder.utils.windows import (set_attached_console_visible,", "from spyder.utils.qthelpers import SpyderProxyStyle", "import win32api", "from spyder.plugins.help.utils.sphinxify import CSS_PATH, DARK_CSS_PATH", "import spyder", "import faulthandler" ]
1,355
1,389
# **** Set high DPI scaling **** # This attribute must be set before creating the application. if hasattr(Qt, 'AA_EnableHighDpiScaling'): QCoreApplication.setAttribute(Qt.AA_EnableHighDpiScaling, CONF.get('main', 'high_dpi_scaling')) # **** Set debugging info **** if get_debug_level() > 0: delete_debug_log_files() setup_logging(options) # **** Create the application **** app = create_application() # **** Create splash screen **** splash = create_splash_screen() if splash is not None: splash.show() splash.showMessage( _("Initializing..."), int(Qt.AlignBottom | Qt.AlignCenter | Qt.AlignAbsolute), QColor(Qt.white) ) QApplication.processEvents() if options.reset_to_defaults: # Reset Spyder settings to defaults CONF.reset_to_defaults() return elif options.optimize: # Optimize the whole Spyder's source code directory import spyder programs.run_python_script(module="compileall", args=[spyder.__path__[0]], p_args=['-O']) return # **** Read faulthandler log file **** faulthandler_file = get_conf_path('faulthandler.log') previous_crash = '' if osp.exists(faulthandler_file): with open(faulthandler_file, 'r') as f: previous_crash = f.read()
mainwindow.py
spyder.spyder.app
false
false
[ "from collections import OrderedDict", "import configparser as cp", "from enum import Enum", "import errno", "import gc", "import logging", "import os", "import os.path as osp", "import shutil", "import signal", "import socket", "import sys", "import threading", "import traceback", "from spyder import requirements", "from qtpy.QtCore import (QCoreApplication, Qt, QTimer, Signal, Slot,", "from qtpy.QtGui import QColor, QKeySequence", "from qtpy.QtWidgets import QApplication, QMainWindow, QMessageBox, QShortcut", "from qtpy import QtSvg # analysis:ignore", "from qtpy import QtWebEngineWidgets # analysis:ignore", "from qtawesome.iconic_font import FontError", "from spyder import __version__", "from spyder.app.find_plugins import (", "from spyder.app.utils import (", "from spyder.api.plugin_registration.registry import PLUGIN_REGISTRY", "from spyder.api.config.mixins import SpyderConfigurationAccessor", "from spyder.api.widgets.mixins import SpyderMainWindowMixin", "from spyder.config.base import (_, DEV, get_conf_path, get_debug_level,", "from spyder.config.gui import is_dark_font_color", "from spyder.config.main import OPEN_FILES_PORT", "from spyder.config.manager import CONF", "from spyder.config.utils import IMPORT_EXT", "from spyder.py3compat import to_text_string", "from spyder.utils import encoding, programs", "from spyder.utils.icon_manager import ima", "from spyder.utils.misc import select_port, getcwd_or_home", "from spyder.utils.palette import QStylePalette", "from spyder.utils.qthelpers import file_uri, qapplication, start_file", "from spyder.utils.stylesheet import APP_STYLESHEET", "from spyder.api.exceptions import SpyderAPIError", "from spyder.api.plugins import (", "from spyder.utils.windows import (set_attached_console_visible,", "from spyder.utils.qthelpers import SpyderProxyStyle", "import win32api", "from spyder.plugins.help.utils.sphinxify import CSS_PATH, DARK_CSS_PATH", "import spyder", "import faulthandler" ]
1,391
1,432
# Remove file to not pick it up for next time. try: dst = get_conf_path('faulthandler.log.old') shutil.move(faulthandler_file, dst) except Exception: pass CONF.set('main', 'previous_crash', previous_crash)
mainwindow.py
spyder.spyder.app
false
false
[ "from collections import OrderedDict", "import configparser as cp", "from enum import Enum", "import errno", "import gc", "import logging", "import os", "import os.path as osp", "import shutil", "import signal", "import socket", "import sys", "import threading", "import traceback", "from spyder import requirements", "from qtpy.QtCore import (QCoreApplication, Qt, QTimer, Signal, Slot,", "from qtpy.QtGui import QColor, QKeySequence", "from qtpy.QtWidgets import QApplication, QMainWindow, QMessageBox, QShortcut", "from qtpy import QtSvg # analysis:ignore", "from qtpy import QtWebEngineWidgets # analysis:ignore", "from qtawesome.iconic_font import FontError", "from spyder import __version__", "from spyder.app.find_plugins import (", "from spyder.app.utils import (", "from spyder.api.plugin_registration.registry import PLUGIN_REGISTRY", "from spyder.api.config.mixins import SpyderConfigurationAccessor", "from spyder.api.widgets.mixins import SpyderMainWindowMixin", "from spyder.config.base import (_, DEV, get_conf_path, get_debug_level,", "from spyder.config.gui import is_dark_font_color", "from spyder.config.main import OPEN_FILES_PORT", "from spyder.config.manager import CONF", "from spyder.config.utils import IMPORT_EXT", "from spyder.py3compat import to_text_string", "from spyder.utils import encoding, programs", "from spyder.utils.icon_manager import ima", "from spyder.utils.misc import select_port, getcwd_or_home", "from spyder.utils.palette import QStylePalette", "from spyder.utils.qthelpers import file_uri, qapplication, start_file", "from spyder.utils.stylesheet import APP_STYLESHEET", "from spyder.api.exceptions import SpyderAPIError", "from spyder.api.plugins import (", "from spyder.utils.windows import (set_attached_console_visible,", "from spyder.utils.qthelpers import SpyderProxyStyle", "import win32api", "from spyder.plugins.help.utils.sphinxify import CSS_PATH, DARK_CSS_PATH", "import spyder", "import faulthandler" ]
1,434
1,440
# **** Create main window **** mainwindow = None try: if options.report_segfault: import faulthandler with open(faulthandler_file, 'w') as f: faulthandler.enable(file=f) mainwindow = create_window( MainWindow, app, splash, options, args ) else: mainwindow = create_window(MainWindow, app, splash, options, args) except FontError: QMessageBox.information( None, "Spyder", "It was not possible to load Spyder's icon theme, so Spyder " "cannot start on your system. The most probable causes for this " "are either that you are using a Windows version earlier than " "Windows 10 1803/Windows Server 2019, which is no longer " "supported by Spyder or Microsoft, or your system administrator " "has disabled font installation for non-admin users. Please " "upgrade Windows or ask your system administrator for help to " "allow Spyder to start." ) if mainwindow is None: # An exception occurred if splash is not None: splash.hide() return ORIGINAL_SYS_EXIT()
mainwindow.py
spyder.spyder.app
false
false
[ "from collections import OrderedDict", "import configparser as cp", "from enum import Enum", "import errno", "import gc", "import logging", "import os", "import os.path as osp", "import shutil", "import signal", "import socket", "import sys", "import threading", "import traceback", "from spyder import requirements", "from qtpy.QtCore import (QCoreApplication, Qt, QTimer, Signal, Slot,", "from qtpy.QtGui import QColor, QKeySequence", "from qtpy.QtWidgets import QApplication, QMainWindow, QMessageBox, QShortcut", "from qtpy import QtSvg # analysis:ignore", "from qtpy import QtWebEngineWidgets # analysis:ignore", "from qtawesome.iconic_font import FontError", "from spyder import __version__", "from spyder.app.find_plugins import (", "from spyder.app.utils import (", "from spyder.api.plugin_registration.registry import PLUGIN_REGISTRY", "from spyder.api.config.mixins import SpyderConfigurationAccessor", "from spyder.api.widgets.mixins import SpyderMainWindowMixin", "from spyder.config.base import (_, DEV, get_conf_path, get_debug_level,", "from spyder.config.gui import is_dark_font_color", "from spyder.config.main import OPEN_FILES_PORT", "from spyder.config.manager import CONF", "from spyder.config.utils import IMPORT_EXT", "from spyder.py3compat import to_text_string", "from spyder.utils import encoding, programs", "from spyder.utils.icon_manager import ima", "from spyder.utils.misc import select_port, getcwd_or_home", "from spyder.utils.palette import QStylePalette", "from spyder.utils.qthelpers import file_uri, qapplication, start_file", "from spyder.utils.stylesheet import APP_STYLESHEET", "from spyder.api.exceptions import SpyderAPIError", "from spyder.api.plugins import (", "from spyder.utils.windows import (set_attached_console_visible,", "from spyder.utils.qthelpers import SpyderProxyStyle", "import win32api", "from spyder.plugins.help.utils.sphinxify import CSS_PATH, DARK_CSS_PATH", "import spyder", "import faulthandler" ]
1,442
1,472
# -*- coding: utf-8 -*- # # Copyright © Spyder Project Contributors # Licensed under the terms of the MIT License # (see spyder/__init__.py for details) """ Spyder, the Scientific Python Development Environment ===================================================== Developed and maintained by the Spyder Project Contributors Copyright © Spyder Project Contributors Licensed under the terms of the MIT License (see spyder/__init__.py for details) """ # ============================================================================= # Stdlib imports # ============================================================================= from collections import OrderedDict import configparser as cp from enum import Enum import errno import gc import logging import os import os.path as osp import shutil import signal import socket import sys import threading import traceback #============================================================================== # Check requirements before proceeding #============================================================================== from spyder import requirements requirements.check_qt()
mainwindow.py
spyder.spyder.app
false
false
[ "from collections import OrderedDict", "import configparser as cp", "from enum import Enum", "import errno", "import gc", "import logging", "import os", "import os.path as osp", "import shutil", "import signal", "import socket", "import sys", "import threading", "import traceback", "from spyder import requirements", "from qtpy.QtCore import (QCoreApplication, Qt, QTimer, Signal, Slot,", "from qtpy.QtGui import QColor, QKeySequence", "from qtpy.QtWidgets import QApplication, QMainWindow, QMessageBox, QShortcut", "from qtpy import QtSvg # analysis:ignore", "from qtpy import QtWebEngineWidgets # analysis:ignore", "from qtawesome.iconic_font import FontError", "from spyder import __version__", "from spyder.app.find_plugins import (", "from spyder.app.utils import (", "from spyder.api.plugin_registration.registry import PLUGIN_REGISTRY", "from spyder.api.config.mixins import SpyderConfigurationAccessor", "from spyder.api.widgets.mixins import SpyderMainWindowMixin", "from spyder.config.base import (_, DEV, get_conf_path, get_debug_level,", "from spyder.config.gui import is_dark_font_color", "from spyder.config.main import OPEN_FILES_PORT", "from spyder.config.manager import CONF", "from spyder.config.utils import IMPORT_EXT", "from spyder.py3compat import to_text_string", "from spyder.utils import encoding, programs", "from spyder.utils.icon_manager import ima", "from spyder.utils.misc import select_port, getcwd_or_home", "from spyder.utils.palette import QStylePalette", "from spyder.utils.qthelpers import file_uri, qapplication, start_file", "from spyder.utils.stylesheet import APP_STYLESHEET", "from spyder.api.exceptions import SpyderAPIError", "from spyder.api.plugins import (", "from spyder.utils.windows import (set_attached_console_visible,", "from spyder.utils.qthelpers import SpyderProxyStyle", "import win32api", "from spyder.plugins.help.utils.sphinxify import CSS_PATH, DARK_CSS_PATH", "import spyder", "import faulthandler" ]
1
41
#============================================================================== # Third-party imports #============================================================================== from qtpy.QtCore import (QCoreApplication, Qt, QTimer, Signal, Slot, qInstallMessageHandler) from qtpy.QtGui import QColor, QKeySequence from qtpy.QtWidgets import QApplication, QMainWindow, QMessageBox, QShortcut # Avoid a "Cannot mix incompatible Qt library" error on Windows platforms from qtpy import QtSvg # analysis:ignore # Avoid a bug in Qt: https://bugreports.qt.io/browse/QTBUG-46720 from qtpy import QtWebEngineWidgets # analysis:ignore from qtawesome.iconic_font import FontError
mainwindow.py
spyder.spyder.app
false
false
[ "from collections import OrderedDict", "import configparser as cp", "from enum import Enum", "import errno", "import gc", "import logging", "import os", "import os.path as osp", "import shutil", "import signal", "import socket", "import sys", "import threading", "import traceback", "from spyder import requirements", "from qtpy.QtCore import (QCoreApplication, Qt, QTimer, Signal, Slot,", "from qtpy.QtGui import QColor, QKeySequence", "from qtpy.QtWidgets import QApplication, QMainWindow, QMessageBox, QShortcut", "from qtpy import QtSvg # analysis:ignore", "from qtpy import QtWebEngineWidgets # analysis:ignore", "from qtawesome.iconic_font import FontError", "from spyder import __version__", "from spyder.app.find_plugins import (", "from spyder.app.utils import (", "from spyder.api.plugin_registration.registry import PLUGIN_REGISTRY", "from spyder.api.config.mixins import SpyderConfigurationAccessor", "from spyder.api.widgets.mixins import SpyderMainWindowMixin", "from spyder.config.base import (_, DEV, get_conf_path, get_debug_level,", "from spyder.config.gui import is_dark_font_color", "from spyder.config.main import OPEN_FILES_PORT", "from spyder.config.manager import CONF", "from spyder.config.utils import IMPORT_EXT", "from spyder.py3compat import to_text_string", "from spyder.utils import encoding, programs", "from spyder.utils.icon_manager import ima", "from spyder.utils.misc import select_port, getcwd_or_home", "from spyder.utils.palette import QStylePalette", "from spyder.utils.qthelpers import file_uri, qapplication, start_file", "from spyder.utils.stylesheet import APP_STYLESHEET", "from spyder.api.exceptions import SpyderAPIError", "from spyder.api.plugins import (", "from spyder.utils.windows import (set_attached_console_visible,", "from spyder.utils.qthelpers import SpyderProxyStyle", "import win32api", "from spyder.plugins.help.utils.sphinxify import CSS_PATH, DARK_CSS_PATH", "import spyder", "import faulthandler" ]
43
57
#============================================================================== # Local imports # NOTE: Move (if possible) import's of widgets and plugins exactly where they # are needed in MainWindow to speed up perceived startup time (i.e. the time # from clicking the Spyder icon to showing the splash screen). #============================================================================== from spyder import __version__ from spyder.app.find_plugins import ( find_external_plugins, find_internal_plugins) from spyder.app.utils import ( create_application, create_splash_screen, create_window, ORIGINAL_SYS_EXIT, delete_debug_log_files, qt_message_handler, set_links_color, setup_logging, set_opengl_implementation) from spyder.api.plugin_registration.registry import PLUGIN_REGISTRY from spyder.api.config.mixins import SpyderConfigurationAccessor from spyder.api.widgets.mixins import SpyderMainWindowMixin from spyder.config.base import (_, DEV, get_conf_path, get_debug_level, get_home_dir, is_conda_based_app, running_under_pytest, STDERR) from spyder.config.gui import is_dark_font_color from spyder.config.main import OPEN_FILES_PORT from spyder.config.manager import CONF from spyder.config.utils import IMPORT_EXT from spyder.py3compat import to_text_string from spyder.utils import encoding, programs from spyder.utils.icon_manager import ima from spyder.utils.misc import select_port, getcwd_or_home
mainwindow.py
spyder.spyder.app
false
false
[ "from collections import OrderedDict", "import configparser as cp", "from enum import Enum", "import errno", "import gc", "import logging", "import os", "import os.path as osp", "import shutil", "import signal", "import socket", "import sys", "import threading", "import traceback", "from spyder import requirements", "from qtpy.QtCore import (QCoreApplication, Qt, QTimer, Signal, Slot,", "from qtpy.QtGui import QColor, QKeySequence", "from qtpy.QtWidgets import QApplication, QMainWindow, QMessageBox, QShortcut", "from qtpy import QtSvg # analysis:ignore", "from qtpy import QtWebEngineWidgets # analysis:ignore", "from qtawesome.iconic_font import FontError", "from spyder import __version__", "from spyder.app.find_plugins import (", "from spyder.app.utils import (", "from spyder.api.plugin_registration.registry import PLUGIN_REGISTRY", "from spyder.api.config.mixins import SpyderConfigurationAccessor", "from spyder.api.widgets.mixins import SpyderMainWindowMixin", "from spyder.config.base import (_, DEV, get_conf_path, get_debug_level,", "from spyder.config.gui import is_dark_font_color", "from spyder.config.main import OPEN_FILES_PORT", "from spyder.config.manager import CONF", "from spyder.config.utils import IMPORT_EXT", "from spyder.py3compat import to_text_string", "from spyder.utils import encoding, programs", "from spyder.utils.icon_manager import ima", "from spyder.utils.misc import select_port, getcwd_or_home", "from spyder.utils.palette import QStylePalette", "from spyder.utils.qthelpers import file_uri, qapplication, start_file", "from spyder.utils.stylesheet import APP_STYLESHEET", "from spyder.api.exceptions import SpyderAPIError", "from spyder.api.plugins import (", "from spyder.utils.windows import (set_attached_console_visible,", "from spyder.utils.qthelpers import SpyderProxyStyle", "import win32api", "from spyder.plugins.help.utils.sphinxify import CSS_PATH, DARK_CSS_PATH", "import spyder", "import faulthandler" ]
59
85
from spyder.py3compat import to_text_string from spyder.utils import encoding, programs from spyder.utils.icon_manager import ima from spyder.utils.misc import select_port, getcwd_or_home from spyder.utils.palette import QStylePalette from spyder.utils.qthelpers import file_uri, qapplication, start_file from spyder.utils.stylesheet import APP_STYLESHEET
mainwindow.py
spyder.spyder.app
false
false
[ "from collections import OrderedDict", "import configparser as cp", "from enum import Enum", "import errno", "import gc", "import logging", "import os", "import os.path as osp", "import shutil", "import signal", "import socket", "import sys", "import threading", "import traceback", "from spyder import requirements", "from qtpy.QtCore import (QCoreApplication, Qt, QTimer, Signal, Slot,", "from qtpy.QtGui import QColor, QKeySequence", "from qtpy.QtWidgets import QApplication, QMainWindow, QMessageBox, QShortcut", "from qtpy import QtSvg # analysis:ignore", "from qtpy import QtWebEngineWidgets # analysis:ignore", "from qtawesome.iconic_font import FontError", "from spyder import __version__", "from spyder.app.find_plugins import (", "from spyder.app.utils import (", "from spyder.api.plugin_registration.registry import PLUGIN_REGISTRY", "from spyder.api.config.mixins import SpyderConfigurationAccessor", "from spyder.api.widgets.mixins import SpyderMainWindowMixin", "from spyder.config.base import (_, DEV, get_conf_path, get_debug_level,", "from spyder.config.gui import is_dark_font_color", "from spyder.config.main import OPEN_FILES_PORT", "from spyder.config.manager import CONF", "from spyder.config.utils import IMPORT_EXT", "from spyder.py3compat import to_text_string", "from spyder.utils import encoding, programs", "from spyder.utils.icon_manager import ima", "from spyder.utils.misc import select_port, getcwd_or_home", "from spyder.utils.palette import QStylePalette", "from spyder.utils.qthelpers import file_uri, qapplication, start_file", "from spyder.utils.stylesheet import APP_STYLESHEET", "from spyder.api.exceptions import SpyderAPIError", "from spyder.api.plugins import (", "from spyder.utils.windows import (set_attached_console_visible,", "from spyder.utils.qthelpers import SpyderProxyStyle", "import win32api", "from spyder.plugins.help.utils.sphinxify import CSS_PATH, DARK_CSS_PATH", "import spyder", "import faulthandler" ]
82
88
# Spyder API Imports from spyder.api.exceptions import SpyderAPIError from spyder.api.plugins import ( Plugins, SpyderPlugin, SpyderPluginV2, SpyderDockablePlugin, SpyderPluginWidget) #============================================================================== # Windows only local imports #============================================================================== set_attached_console_visible = None is_attached_console_visible = None set_windows_appusermodelid = None if os.name == 'nt': from spyder.utils.windows import (set_attached_console_visible, set_windows_appusermodelid) #============================================================================== # Constants #============================================================================== # Module logger logger = logging.getLogger(__name__) #============================================================================== # Install Qt messaage handler #============================================================================== qInstallMessageHandler(qt_message_handler) #============================================================================== # Main Window #============================================================================== # Code for: class MainWindow(
mainwindow.py
spyder.spyder.app
false
false
[ "from collections import OrderedDict", "import configparser as cp", "from enum import Enum", "import errno", "import gc", "import logging", "import os", "import os.path as osp", "import shutil", "import signal", "import socket", "import sys", "import threading", "import traceback", "from spyder import requirements", "from qtpy.QtCore import (QCoreApplication, Qt, QTimer, Signal, Slot,", "from qtpy.QtGui import QColor, QKeySequence", "from qtpy.QtWidgets import QApplication, QMainWindow, QMessageBox, QShortcut", "from qtpy import QtSvg # analysis:ignore", "from qtpy import QtWebEngineWidgets # analysis:ignore", "from qtawesome.iconic_font import FontError", "from spyder import __version__", "from spyder.app.find_plugins import (", "from spyder.app.utils import (", "from spyder.api.plugin_registration.registry import PLUGIN_REGISTRY", "from spyder.api.config.mixins import SpyderConfigurationAccessor", "from spyder.api.widgets.mixins import SpyderMainWindowMixin", "from spyder.config.base import (_, DEV, get_conf_path, get_debug_level,", "from spyder.config.gui import is_dark_font_color", "from spyder.config.main import OPEN_FILES_PORT", "from spyder.config.manager import CONF", "from spyder.config.utils import IMPORT_EXT", "from spyder.py3compat import to_text_string", "from spyder.utils import encoding, programs", "from spyder.utils.icon_manager import ima", "from spyder.utils.misc import select_port, getcwd_or_home", "from spyder.utils.palette import QStylePalette", "from spyder.utils.qthelpers import file_uri, qapplication, start_file", "from spyder.utils.stylesheet import APP_STYLESHEET", "from spyder.api.exceptions import SpyderAPIError", "from spyder.api.plugins import (", "from spyder.utils.windows import (set_attached_console_visible,", "from spyder.utils.qthelpers import SpyderProxyStyle", "import win32api", "from spyder.plugins.help.utils.sphinxify import CSS_PATH, DARK_CSS_PATH", "import spyder", "import faulthandler" ]
90
121
#============================================================================== # Main #============================================================================== # Code for: def main(options, args): if __name__ == "__main__": main()
mainwindow.py
spyder.spyder.app
false
true
[ "from collections import OrderedDict", "import configparser as cp", "from enum import Enum", "import errno", "import gc", "import logging", "import os", "import os.path as osp", "import shutil", "import signal", "import socket", "import sys", "import threading", "import traceback", "from spyder import requirements", "from qtpy.QtCore import (QCoreApplication, Qt, QTimer, Signal, Slot,", "from qtpy.QtGui import QColor, QKeySequence", "from qtpy.QtWidgets import QApplication, QMainWindow, QMessageBox, QShortcut", "from qtpy import QtSvg # analysis:ignore", "from qtpy import QtWebEngineWidgets # analysis:ignore", "from qtawesome.iconic_font import FontError", "from spyder import __version__", "from spyder.app.find_plugins import (", "from spyder.app.utils import (", "from spyder.api.plugin_registration.registry import PLUGIN_REGISTRY", "from spyder.api.config.mixins import SpyderConfigurationAccessor", "from spyder.api.widgets.mixins import SpyderMainWindowMixin", "from spyder.config.base import (_, DEV, get_conf_path, get_debug_level,", "from spyder.config.gui import is_dark_font_color", "from spyder.config.main import OPEN_FILES_PORT", "from spyder.config.manager import CONF", "from spyder.config.utils import IMPORT_EXT", "from spyder.py3compat import to_text_string", "from spyder.utils import encoding, programs", "from spyder.utils.icon_manager import ima", "from spyder.utils.misc import select_port, getcwd_or_home", "from spyder.utils.palette import QStylePalette", "from spyder.utils.qthelpers import file_uri, qapplication, start_file", "from spyder.utils.stylesheet import APP_STYLESHEET", "from spyder.api.exceptions import SpyderAPIError", "from spyder.api.plugins import (", "from spyder.utils.windows import (set_attached_console_visible,", "from spyder.utils.qthelpers import SpyderProxyStyle", "import win32api", "from spyder.plugins.help.utils.sphinxify import CSS_PATH, DARK_CSS_PATH", "import spyder", "import faulthandler" ]
1,352
1,359
def open_file_in_editor(main_window, fname, directory=None): """Open a file using the Editor and its open file dialog""" top_level_widgets = QApplication.topLevelWidgets() for w in top_level_widgets: if isinstance(w, QFileDialog): if directory is not None: w.setDirectory(directory) input_field = w.findChildren(QLineEdit)[0] input_field.setText(fname) QTest.keyClick(w, Qt.Key_Enter)
conftest.py
spyder.spyder.app.tests
false
true
[ "import os", "import os.path as osp", "import sys", "import threading", "import traceback", "from jupyter_client.manager import KernelManager", "from qtpy.QtCore import Qt", "from qtpy.QtTest import QTest", "from qtpy.QtWidgets import QApplication, QFileDialog, QLineEdit, QTabBar", "from qtpy import QtWebEngineWidgets # noqa", "import psutil", "import pytest", "from spyder.api.plugins import Plugins", "from spyder.app import start", "from spyder.config.base import get_home_dir, running_in_ci", "from spyder.config.manager import CONF", "from spyder.plugins.ipythonconsole.utils.kernelspec import SpyderKernelSpec", "from spyder.plugins.projects.api import EmptyProject", "from spyder.plugins.run.api import RunActions, StoredRunConfigurationExecutor", "from spyder.plugins.toolbar.api import ApplicationToolbars", "from spyder.utils import encoding", "from spyder.utils.environ import (get_user_env, set_user_env,", "from spyder.api.plugin_registration.registry import PLUGIN_REGISTRY" ]
64
73
def reset_run_code(qtbot, shell, code_editor, nsb): """Reset state after a run code test""" qtbot.waitUntil(lambda: not shell._executing) with qtbot.waitSignal(shell.executed): shell.execute('%reset -f') qtbot.waitUntil( lambda: nsb.editor.source_model.rowCount() == 0, timeout=EVAL_TIMEOUT) code_editor.setFocus() qtbot.keyClick(code_editor, Qt.Key_Home, modifier=Qt.ControlModifier)
conftest.py
spyder.spyder.app.tests
false
true
[ "import os", "import os.path as osp", "import sys", "import threading", "import traceback", "from jupyter_client.manager import KernelManager", "from qtpy.QtCore import Qt", "from qtpy.QtTest import QTest", "from qtpy.QtWidgets import QApplication, QFileDialog, QLineEdit, QTabBar", "from qtpy import QtWebEngineWidgets # noqa", "import psutil", "import pytest", "from spyder.api.plugins import Plugins", "from spyder.app import start", "from spyder.config.base import get_home_dir, running_in_ci", "from spyder.config.manager import CONF", "from spyder.plugins.ipythonconsole.utils.kernelspec import SpyderKernelSpec", "from spyder.plugins.projects.api import EmptyProject", "from spyder.plugins.run.api import RunActions, StoredRunConfigurationExecutor", "from spyder.plugins.toolbar.api import ApplicationToolbars", "from spyder.utils import encoding", "from spyder.utils.environ import (get_user_env, set_user_env,", "from spyder.api.plugin_registration.registry import PLUGIN_REGISTRY" ]
76
84
def start_new_kernel(startup_timeout=60, kernel_name='python', spykernel=False, **kwargs): """Start a new kernel, and return its Manager and Client""" km = KernelManager(kernel_name=kernel_name) if spykernel: km._kernel_spec = SpyderKernelSpec() km.start_kernel(**kwargs) kc = km.client() kc.start_channels() try: kc.wait_for_ready(timeout=startup_timeout) except RuntimeError: kc.stop_channels() km.shutdown_kernel() raise return km, kc
conftest.py
spyder.spyder.app.tests
false
false
[ "import os", "import os.path as osp", "import sys", "import threading", "import traceback", "from jupyter_client.manager import KernelManager", "from qtpy.QtCore import Qt", "from qtpy.QtTest import QTest", "from qtpy.QtWidgets import QApplication, QFileDialog, QLineEdit, QTabBar", "from qtpy import QtWebEngineWidgets # noqa", "import psutil", "import pytest", "from spyder.api.plugins import Plugins", "from spyder.app import start", "from spyder.config.base import get_home_dir, running_in_ci", "from spyder.config.manager import CONF", "from spyder.plugins.ipythonconsole.utils.kernelspec import SpyderKernelSpec", "from spyder.plugins.projects.api import EmptyProject", "from spyder.plugins.run.api import RunActions, StoredRunConfigurationExecutor", "from spyder.plugins.toolbar.api import ApplicationToolbars", "from spyder.utils import encoding", "from spyder.utils.environ import (get_user_env, set_user_env,", "from spyder.api.plugin_registration.registry import PLUGIN_REGISTRY" ]
87
103
def find_desired_tab_in_window(tab_name, window): all_tabbars = window.findChildren(QTabBar) for current_tabbar in all_tabbars: for tab_index in range(current_tabbar.count()): if current_tabbar.tabText(tab_index) == str(tab_name): return current_tabbar, tab_index return None, None
conftest.py
spyder.spyder.app.tests
false
true
[ "import os", "import os.path as osp", "import sys", "import threading", "import traceback", "from jupyter_client.manager import KernelManager", "from qtpy.QtCore import Qt", "from qtpy.QtTest import QTest", "from qtpy.QtWidgets import QApplication, QFileDialog, QLineEdit, QTabBar", "from qtpy import QtWebEngineWidgets # noqa", "import psutil", "import pytest", "from spyder.api.plugins import Plugins", "from spyder.app import start", "from spyder.config.base import get_home_dir, running_in_ci", "from spyder.config.manager import CONF", "from spyder.plugins.ipythonconsole.utils.kernelspec import SpyderKernelSpec", "from spyder.plugins.projects.api import EmptyProject", "from spyder.plugins.run.api import RunActions, StoredRunConfigurationExecutor", "from spyder.plugins.toolbar.api import ApplicationToolbars", "from spyder.utils import encoding", "from spyder.utils.environ import (get_user_env, set_user_env,", "from spyder.api.plugin_registration.registry import PLUGIN_REGISTRY" ]
106
112
def read_asset_file(filename): """Read contents of an asset file.""" return encoding.read(osp.join(LOCATION, filename))[0]
conftest.py
spyder.spyder.app.tests
false
true
[ "import os", "import os.path as osp", "import sys", "import threading", "import traceback", "from jupyter_client.manager import KernelManager", "from qtpy.QtCore import Qt", "from qtpy.QtTest import QTest", "from qtpy.QtWidgets import QApplication, QFileDialog, QLineEdit, QTabBar", "from qtpy import QtWebEngineWidgets # noqa", "import psutil", "import pytest", "from spyder.api.plugins import Plugins", "from spyder.app import start", "from spyder.config.base import get_home_dir, running_in_ci", "from spyder.config.manager import CONF", "from spyder.plugins.ipythonconsole.utils.kernelspec import SpyderKernelSpec", "from spyder.plugins.projects.api import EmptyProject", "from spyder.plugins.run.api import RunActions, StoredRunConfigurationExecutor", "from spyder.plugins.toolbar.api import ApplicationToolbars", "from spyder.utils import encoding", "from spyder.utils.environ import (get_user_env, set_user_env,", "from spyder.api.plugin_registration.registry import PLUGIN_REGISTRY" ]
115
117
def create_project(tmpdir): """Create a simple project.""" # Create project directory project = tmpdir.mkdir('test_project') project_path = str(project) # Create Spyder project spy_project = EmptyProject(project_path) CONF.set('project_explorer', 'current_project_path', project_path) # Add a file to the project p_file = project.join('file.py') p_file.write(read_asset_file('script_outline_1.py')) spy_project.set_recent_files([str(p_file)])
conftest.py
spyder.spyder.app.tests
false
true
[ "import os", "import os.path as osp", "import sys", "import threading", "import traceback", "from jupyter_client.manager import KernelManager", "from qtpy.QtCore import Qt", "from qtpy.QtTest import QTest", "from qtpy.QtWidgets import QApplication, QFileDialog, QLineEdit, QTabBar", "from qtpy import QtWebEngineWidgets # noqa", "import psutil", "import pytest", "from spyder.api.plugins import Plugins", "from spyder.app import start", "from spyder.config.base import get_home_dir, running_in_ci", "from spyder.config.manager import CONF", "from spyder.plugins.ipythonconsole.utils.kernelspec import SpyderKernelSpec", "from spyder.plugins.projects.api import EmptyProject", "from spyder.plugins.run.api import RunActions, StoredRunConfigurationExecutor", "from spyder.plugins.toolbar.api import ApplicationToolbars", "from spyder.utils import encoding", "from spyder.utils.environ import (get_user_env, set_user_env,", "from spyder.api.plugin_registration.registry import PLUGIN_REGISTRY" ]
120
133
def create_complex_project(tmpdir): """Create a complex project.""" # Create project directories project = tmpdir.mkdir('test_project') project_subdir = project.mkdir('subdir') project_sub_subdir = project_subdir.mkdir('sub_subdir') # Create directories out of the project out_of_project_1 = tmpdir.mkdir('out_of_project_1') out_of_project_2 = tmpdir.mkdir('out_of_project_2') out_of_project_1_subdir = out_of_project_1.mkdir('subdir') out_of_project_2_subdir = out_of_project_2.mkdir('subdir') project_path = str(project) spy_project = EmptyProject(project_path) CONF.set('project_explorer', 'current_project_path', project_path) # Add some files to project. This is necessary to test that we get # symbols for all these files. abs_filenames = [] filenames_to_create = { project: ['file1.py', 'file2.py', 'file3.txt', '__init__.py'], project_subdir: ['a.py', '__init__.py'], project_sub_subdir: ['b.py', '__init__.py'], out_of_project_1: ['c.py'], out_of_project_2: ['d.py', '__init__.py'], out_of_project_1_subdir: ['e.py', '__init__.py'], out_of_project_2_subdir: ['f.py'] }
conftest.py
spyder.spyder.app.tests
false
true
[ "import os", "import os.path as osp", "import sys", "import threading", "import traceback", "from jupyter_client.manager import KernelManager", "from qtpy.QtCore import Qt", "from qtpy.QtTest import QTest", "from qtpy.QtWidgets import QApplication, QFileDialog, QLineEdit, QTabBar", "from qtpy import QtWebEngineWidgets # noqa", "import psutil", "import pytest", "from spyder.api.plugins import Plugins", "from spyder.app import start", "from spyder.config.base import get_home_dir, running_in_ci", "from spyder.config.manager import CONF", "from spyder.plugins.ipythonconsole.utils.kernelspec import SpyderKernelSpec", "from spyder.plugins.projects.api import EmptyProject", "from spyder.plugins.run.api import RunActions, StoredRunConfigurationExecutor", "from spyder.plugins.toolbar.api import ApplicationToolbars", "from spyder.utils import encoding", "from spyder.utils.environ import (get_user_env, set_user_env,", "from spyder.api.plugin_registration.registry import PLUGIN_REGISTRY" ]
136
164
for path in filenames_to_create.keys(): filenames = filenames_to_create[path] for filename in filenames: p_file = path.join(filename) abs_filenames.append(str(p_file)) if osp.splitext(filename)[1] == '.py': if path == project_subdir: code = read_asset_file('script_outline_2.py') elif path == project_sub_subdir: code = read_asset_file('script_outline_3.py') else: code = read_asset_file('script_outline_1.py') p_file.write(code) else: p_file.write("Hello world!") spy_project.set_recent_files(abs_filenames)
conftest.py
spyder.spyder.app.tests
false
false
[ "import os", "import os.path as osp", "import sys", "import threading", "import traceback", "from jupyter_client.manager import KernelManager", "from qtpy.QtCore import Qt", "from qtpy.QtTest import QTest", "from qtpy.QtWidgets import QApplication, QFileDialog, QLineEdit, QTabBar", "from qtpy import QtWebEngineWidgets # noqa", "import psutil", "import pytest", "from spyder.api.plugins import Plugins", "from spyder.app import start", "from spyder.config.base import get_home_dir, running_in_ci", "from spyder.config.manager import CONF", "from spyder.plugins.ipythonconsole.utils.kernelspec import SpyderKernelSpec", "from spyder.plugins.projects.api import EmptyProject", "from spyder.plugins.run.api import RunActions, StoredRunConfigurationExecutor", "from spyder.plugins.toolbar.api import ApplicationToolbars", "from spyder.utils import encoding", "from spyder.utils.environ import (get_user_env, set_user_env,", "from spyder.api.plugin_registration.registry import PLUGIN_REGISTRY" ]
166
182
def create_namespace_project(tmpdir): """Create a project that contains a namespace package.""" # Create project as example posted in: # https://github.com/spyder-ide/spyder/issues/16406#issuecomment-917992317 project = tmpdir.mkdir('namespace-project') ns_package = project.mkdir('namespace-package') sub_package = ns_package.mkdir('sub-package') project_path = str(project) spy_project = EmptyProject(project_path) CONF.set('project_explorer', 'current_project_path', project_path) # Add some files to sub-package. abs_filenames = [] filenames_to_create = {sub_package: ['module_1.py', '__init__.py']} for path in filenames_to_create.keys(): filenames = filenames_to_create[path] for filename in filenames: p_file = path.join(filename) abs_filenames.append(str(p_file)) # Use different files to be extra sure we're loading symbols in # each case. if filename == 'module.py': code = read_asset_file('script_outline_4.py') else: code = read_asset_file('script_outline_1.py') p_file.write(code) spy_project.set_recent_files(abs_filenames)
conftest.py
spyder.spyder.app.tests
false
true
[ "import os", "import os.path as osp", "import sys", "import threading", "import traceback", "from jupyter_client.manager import KernelManager", "from qtpy.QtCore import Qt", "from qtpy.QtTest import QTest", "from qtpy.QtWidgets import QApplication, QFileDialog, QLineEdit, QTabBar", "from qtpy import QtWebEngineWidgets # noqa", "import psutil", "import pytest", "from spyder.api.plugins import Plugins", "from spyder.app import start", "from spyder.config.base import get_home_dir, running_in_ci", "from spyder.config.manager import CONF", "from spyder.plugins.ipythonconsole.utils.kernelspec import SpyderKernelSpec", "from spyder.plugins.projects.api import EmptyProject", "from spyder.plugins.run.api import RunActions, StoredRunConfigurationExecutor", "from spyder.plugins.toolbar.api import ApplicationToolbars", "from spyder.utils import encoding", "from spyder.utils.environ import (get_user_env, set_user_env,", "from spyder.api.plugin_registration.registry import PLUGIN_REGISTRY" ]
185
216
def preferences_dialog_helper(qtbot, main_window, section): """ Open preferences dialog and select page with `section` (CONF_SECTION). """ # Wait until the window is fully up shell = main_window.ipyconsole.get_current_shellwidget() qtbot.waitUntil( lambda: shell.spyder_kernel_ready and shell._prompt_html is not None, timeout=SHELL_TIMEOUT ) main_window.show_preferences() preferences = main_window.preferences container = preferences.get_container() qtbot.waitUntil(lambda: container.dialog is not None, timeout=5000) dlg = container.dialog index = dlg.get_index_by_name(section) page = dlg.get_page(index) dlg.set_current_index(index) return dlg, index, page
conftest.py
spyder.spyder.app.tests
false
true
[ "import os", "import os.path as osp", "import sys", "import threading", "import traceback", "from jupyter_client.manager import KernelManager", "from qtpy.QtCore import Qt", "from qtpy.QtTest import QTest", "from qtpy.QtWidgets import QApplication, QFileDialog, QLineEdit, QTabBar", "from qtpy import QtWebEngineWidgets # noqa", "import psutil", "import pytest", "from spyder.api.plugins import Plugins", "from spyder.app import start", "from spyder.config.base import get_home_dir, running_in_ci", "from spyder.config.manager import CONF", "from spyder.plugins.ipythonconsole.utils.kernelspec import SpyderKernelSpec", "from spyder.plugins.projects.api import EmptyProject", "from spyder.plugins.run.api import RunActions, StoredRunConfigurationExecutor", "from spyder.plugins.toolbar.api import ApplicationToolbars", "from spyder.utils import encoding", "from spyder.utils.environ import (get_user_env, set_user_env,", "from spyder.api.plugin_registration.registry import PLUGIN_REGISTRY" ]
219
239
def generate_run_parameters(mainwindow, filename, selected=None, executor=None): """Generate run configuration parameters for a given filename.""" file_uuid = mainwindow.editor.id_per_file[filename] if executor is None: executor = mainwindow.ipyconsole.NAME file_run_params = StoredRunConfigurationExecutor( executor=executor, selected=selected, display_dialog=False ) return {file_uuid: file_run_params}
conftest.py
spyder.spyder.app.tests
false
false
[ "import os", "import os.path as osp", "import sys", "import threading", "import traceback", "from jupyter_client.manager import KernelManager", "from qtpy.QtCore import Qt", "from qtpy.QtTest import QTest", "from qtpy.QtWidgets import QApplication, QFileDialog, QLineEdit, QTabBar", "from qtpy import QtWebEngineWidgets # noqa", "import psutil", "import pytest", "from spyder.api.plugins import Plugins", "from spyder.app import start", "from spyder.config.base import get_home_dir, running_in_ci", "from spyder.config.manager import CONF", "from spyder.plugins.ipythonconsole.utils.kernelspec import SpyderKernelSpec", "from spyder.plugins.projects.api import EmptyProject", "from spyder.plugins.run.api import RunActions, StoredRunConfigurationExecutor", "from spyder.plugins.toolbar.api import ApplicationToolbars", "from spyder.utils import encoding", "from spyder.utils.environ import (get_user_env, set_user_env,", "from spyder.api.plugin_registration.registry import PLUGIN_REGISTRY" ]
242
255
def pytest_runtest_makereport(item, call): # execute all other hooks to obtain the report object outcome = yield rep = outcome.get_result() # set a report attribute for each phase of a call, which can # be "setup", "call", "teardown" setattr(item, "rep_" + rep.when, rep)
conftest.py
spyder.spyder.app.tests
false
true
[ "import os", "import os.path as osp", "import sys", "import threading", "import traceback", "from jupyter_client.manager import KernelManager", "from qtpy.QtCore import Qt", "from qtpy.QtTest import QTest", "from qtpy.QtWidgets import QApplication, QFileDialog, QLineEdit, QTabBar", "from qtpy import QtWebEngineWidgets # noqa", "import psutil", "import pytest", "from spyder.api.plugins import Plugins", "from spyder.app import start", "from spyder.config.base import get_home_dir, running_in_ci", "from spyder.config.manager import CONF", "from spyder.plugins.ipythonconsole.utils.kernelspec import SpyderKernelSpec", "from spyder.plugins.projects.api import EmptyProject", "from spyder.plugins.run.api import RunActions, StoredRunConfigurationExecutor", "from spyder.plugins.toolbar.api import ApplicationToolbars", "from spyder.utils import encoding", "from spyder.utils.environ import (get_user_env, set_user_env,", "from spyder.api.plugin_registration.registry import PLUGIN_REGISTRY" ]
262
269
def cleanup(request, qapp): """Cleanup the testing setup once we are finished.""" def close_window(): # Close last used mainwindow and QApplication if needed if hasattr(main_window, 'window') and main_window.window is not None: window = main_window.window main_window.window = None window.close() window = None CONF.reset_to_defaults(notification=False) if qapp.instance(): qapp.quit() request.addfinalizer(close_window)
conftest.py
spyder.spyder.app.tests
false
true
[ "import os", "import os.path as osp", "import sys", "import threading", "import traceback", "from jupyter_client.manager import KernelManager", "from qtpy.QtCore import Qt", "from qtpy.QtTest import QTest", "from qtpy.QtWidgets import QApplication, QFileDialog, QLineEdit, QTabBar", "from qtpy import QtWebEngineWidgets # noqa", "import psutil", "import pytest", "from spyder.api.plugins import Plugins", "from spyder.app import start", "from spyder.config.base import get_home_dir, running_in_ci", "from spyder.config.manager import CONF", "from spyder.plugins.ipythonconsole.utils.kernelspec import SpyderKernelSpec", "from spyder.plugins.projects.api import EmptyProject", "from spyder.plugins.run.api import RunActions, StoredRunConfigurationExecutor", "from spyder.plugins.toolbar.api import ApplicationToolbars", "from spyder.utils import encoding", "from spyder.utils.environ import (get_user_env, set_user_env,", "from spyder.api.plugin_registration.registry import PLUGIN_REGISTRY" ]
276
290
def main_window(request, tmpdir, qtbot): """Main Window fixture""" # Get original processEvents function in case the test that overrides it # fails super_processEvents = QApplication.processEvents # Don't show tours message CONF.set('tours', 'show_tour_message', False) # Tests assume inline backend CONF.set('ipython_console', 'pylab/backend', 'inline') # Test assume the plots are rendered in the console as png CONF.set('plots', 'mute_inline_plotting', False) CONF.set('ipython_console', 'pylab/inline/figure_format', "png") # Set exclamation mark to True CONF.set('debugger', 'pdb_use_exclamation_mark', True) # Check if we need to use introspection in a given test # (it's faster and less memory consuming not to use it!) use_introspection = request.node.get_closest_marker('use_introspection') if use_introspection: os.environ['SPY_TEST_USE_INTROSPECTION'] = 'True' else: try: os.environ.pop('SPY_TEST_USE_INTROSPECTION') except KeyError: pass # Only use single_instance mode for tests that require it single_instance = request.node.get_closest_marker('single_instance') if single_instance: CONF.set('main', 'single_instance', True) else: CONF.set('main', 'single_instance', False)
conftest.py
spyder.spyder.app.tests
false
true
[ "import os", "import os.path as osp", "import sys", "import threading", "import traceback", "from jupyter_client.manager import KernelManager", "from qtpy.QtCore import Qt", "from qtpy.QtTest import QTest", "from qtpy.QtWidgets import QApplication, QFileDialog, QLineEdit, QTabBar", "from qtpy import QtWebEngineWidgets # noqa", "import psutil", "import pytest", "from spyder.api.plugins import Plugins", "from spyder.app import start", "from spyder.config.base import get_home_dir, running_in_ci", "from spyder.config.manager import CONF", "from spyder.plugins.ipythonconsole.utils.kernelspec import SpyderKernelSpec", "from spyder.plugins.projects.api import EmptyProject", "from spyder.plugins.run.api import RunActions, StoredRunConfigurationExecutor", "from spyder.plugins.toolbar.api import ApplicationToolbars", "from spyder.utils import encoding", "from spyder.utils.environ import (get_user_env, set_user_env,", "from spyder.api.plugin_registration.registry import PLUGIN_REGISTRY" ]
294
332
if single_instance: CONF.set('main', 'single_instance', True) else: CONF.set('main', 'single_instance', False) # Check if we need to load a simple project to the interface preload_project = request.node.get_closest_marker('preload_project') if preload_project: create_project(tmpdir) else: CONF.set('project_explorer', 'current_project_path', None) # Check if we need to preload a complex project in a give test preload_complex_project = request.node.get_closest_marker( 'preload_complex_project') if preload_complex_project: CONF.set('editor', 'show_class_func_dropdown', True) create_complex_project(tmpdir) else: CONF.set('editor', 'show_class_func_dropdown', False) if not preload_project: CONF.set('project_explorer', 'current_project_path', None) # Check if we need to preload a project with a namespace package preload_namespace_project = request.node.get_closest_marker( 'preload_namespace_project') if preload_namespace_project: create_namespace_project(tmpdir) else: if not (preload_project or preload_complex_project): CONF.set('project_explorer', 'current_project_path', None)
conftest.py
spyder.spyder.app.tests
false
false
[ "import os", "import os.path as osp", "import sys", "import threading", "import traceback", "from jupyter_client.manager import KernelManager", "from qtpy.QtCore import Qt", "from qtpy.QtTest import QTest", "from qtpy.QtWidgets import QApplication, QFileDialog, QLineEdit, QTabBar", "from qtpy import QtWebEngineWidgets # noqa", "import psutil", "import pytest", "from spyder.api.plugins import Plugins", "from spyder.app import start", "from spyder.config.base import get_home_dir, running_in_ci", "from spyder.config.manager import CONF", "from spyder.plugins.ipythonconsole.utils.kernelspec import SpyderKernelSpec", "from spyder.plugins.projects.api import EmptyProject", "from spyder.plugins.run.api import RunActions, StoredRunConfigurationExecutor", "from spyder.plugins.toolbar.api import ApplicationToolbars", "from spyder.utils import encoding", "from spyder.utils.environ import (get_user_env, set_user_env,", "from spyder.api.plugin_registration.registry import PLUGIN_REGISTRY" ]
329
359
# Get config values passed in parametrize and apply them try: param = request.param if isinstance(param, dict) and 'spy_config' in param: CONF.set(*param['spy_config']) except AttributeError: # Not all tests that use this fixture define request.param pass QApplication.processEvents() if not hasattr(main_window, 'window') or main_window.window is None: from spyder.api.plugin_registration.registry import PLUGIN_REGISTRY PLUGIN_REGISTRY.reset() # Start the window window = start.main() main_window.window = window else: window = main_window.window if not request.node.get_closest_marker('no_new_console'): # Create a new console to ensure new config is loaded # even if the same mainwindow instance is reused window.ipyconsole.create_new_client(give_focus=True) # Add a handle to the "Debug file" button to access it quickly because # it's used a lot. toolbar = window.get_plugin(Plugins.Toolbar) debug_toolbar = toolbar.get_application_toolbar(ApplicationToolbars.Debug) debug_action = window.run.get_action( "run file in debugger") debug_button = debug_toolbar.widgetForAction(debug_action) window.debug_button = debug_button
conftest.py
spyder.spyder.app.tests
false
false
[ "import os", "import os.path as osp", "import sys", "import threading", "import traceback", "from jupyter_client.manager import KernelManager", "from qtpy.QtCore import Qt", "from qtpy.QtTest import QTest", "from qtpy.QtWidgets import QApplication, QFileDialog, QLineEdit, QTabBar", "from qtpy import QtWebEngineWidgets # noqa", "import psutil", "import pytest", "from spyder.api.plugins import Plugins", "from spyder.app import start", "from spyder.config.base import get_home_dir, running_in_ci", "from spyder.config.manager import CONF", "from spyder.plugins.ipythonconsole.utils.kernelspec import SpyderKernelSpec", "from spyder.plugins.projects.api import EmptyProject", "from spyder.plugins.run.api import RunActions, StoredRunConfigurationExecutor", "from spyder.plugins.toolbar.api import ApplicationToolbars", "from spyder.utils import encoding", "from spyder.utils.environ import (get_user_env, set_user_env,", "from spyder.api.plugin_registration.registry import PLUGIN_REGISTRY" ]
361
395
# Add a handle to the run buttons to access it quickly because they are # used a lot. run_toolbar = toolbar.get_application_toolbar(ApplicationToolbars.Run) run_action = window.run.get_action(RunActions.Run) run_button = run_toolbar.widgetForAction(run_action) window.run_button = run_button run_cell_action = window.run.get_action('run cell') run_cell_button = run_toolbar.widgetForAction(run_cell_action) window.run_cell_button = run_cell_button run_cell_and_advance_action = window.run.get_action('run cell and advance') run_cell_and_advance_button = run_toolbar.widgetForAction( run_cell_and_advance_action) window.run_cell_and_advance_button = run_cell_and_advance_button run_selection_action = window.run.get_action('run selection and advance') run_selection_button = run_toolbar.widgetForAction(run_selection_action) window.run_selection_button = run_selection_button QApplication.processEvents() if os.name != 'nt': # _DummyThread are created if current_thread() is called from them. # They will always leak (From python doc) so we ignore them. init_threads = [ repr(thread) for thread in threading.enumerate() if not isinstance(thread, threading._DummyThread)] proc = psutil.Process() init_files = [repr(f) for f in proc.open_files()] init_subprocesses = [repr(f) for f in proc.children()] yield window
conftest.py
spyder.spyder.app.tests
false
false
[ "import os", "import os.path as osp", "import sys", "import threading", "import traceback", "from jupyter_client.manager import KernelManager", "from qtpy.QtCore import Qt", "from qtpy.QtTest import QTest", "from qtpy.QtWidgets import QApplication, QFileDialog, QLineEdit, QTabBar", "from qtpy import QtWebEngineWidgets # noqa", "import psutil", "import pytest", "from spyder.api.plugins import Plugins", "from spyder.app import start", "from spyder.config.base import get_home_dir, running_in_ci", "from spyder.config.manager import CONF", "from spyder.plugins.ipythonconsole.utils.kernelspec import SpyderKernelSpec", "from spyder.plugins.projects.api import EmptyProject", "from spyder.plugins.run.api import RunActions, StoredRunConfigurationExecutor", "from spyder.plugins.toolbar.api import ApplicationToolbars", "from spyder.utils import encoding", "from spyder.utils.environ import (get_user_env, set_user_env,", "from spyder.api.plugin_registration.registry import PLUGIN_REGISTRY" ]
397
429
yield window # Remap original QApplication.processEvents function QApplication.processEvents = super_processEvents
conftest.py
spyder.spyder.app.tests
false
false
[ "import os", "import os.path as osp", "import sys", "import threading", "import traceback", "from jupyter_client.manager import KernelManager", "from qtpy.QtCore import Qt", "from qtpy.QtTest import QTest", "from qtpy.QtWidgets import QApplication, QFileDialog, QLineEdit, QTabBar", "from qtpy import QtWebEngineWidgets # noqa", "import psutil", "import pytest", "from spyder.api.plugins import Plugins", "from spyder.app import start", "from spyder.config.base import get_home_dir, running_in_ci", "from spyder.config.manager import CONF", "from spyder.plugins.ipythonconsole.utils.kernelspec import SpyderKernelSpec", "from spyder.plugins.projects.api import EmptyProject", "from spyder.plugins.run.api import RunActions, StoredRunConfigurationExecutor", "from spyder.plugins.toolbar.api import ApplicationToolbars", "from spyder.utils import encoding", "from spyder.utils.environ import (get_user_env, set_user_env,", "from spyder.api.plugin_registration.registry import PLUGIN_REGISTRY" ]
429
432
# Print shell content if failed if request.node.rep_setup.passed: if request.node.rep_call.failed: # Print content of shellwidget and close window print(window.ipyconsole.get_current_shellwidget( )._control.toPlainText()) # Print info page content is not blank console = window.ipyconsole client = console.get_current_client() if client.info_page != client.blank_page: print('info_page') print(client.info_page) main_window.window = None window.close() window = None CONF.reset_to_defaults(notification=False) else: # Try to close used mainwindow directly on fixture # after running test that uses the fixture # Currently 'test_out_runfile_runcell' is the last tests so # in order to prevent errors finalizing the test suit such test has # this marker close_main_window = request.node.get_closest_marker( 'close_main_window') if close_main_window: main_window.window = None window.close() window = None CONF.reset_to_defaults(notification=False) else: try: # Close or hide everything we can think of window.switcher.hide()
conftest.py
spyder.spyder.app.tests
false
false
[ "import os", "import os.path as osp", "import sys", "import threading", "import traceback", "from jupyter_client.manager import KernelManager", "from qtpy.QtCore import Qt", "from qtpy.QtTest import QTest", "from qtpy.QtWidgets import QApplication, QFileDialog, QLineEdit, QTabBar", "from qtpy import QtWebEngineWidgets # noqa", "import psutil", "import pytest", "from spyder.api.plugins import Plugins", "from spyder.app import start", "from spyder.config.base import get_home_dir, running_in_ci", "from spyder.config.manager import CONF", "from spyder.plugins.ipythonconsole.utils.kernelspec import SpyderKernelSpec", "from spyder.plugins.projects.api import EmptyProject", "from spyder.plugins.run.api import RunActions, StoredRunConfigurationExecutor", "from spyder.plugins.toolbar.api import ApplicationToolbars", "from spyder.utils import encoding", "from spyder.utils.environ import (get_user_env, set_user_env,", "from spyder.api.plugin_registration.registry import PLUGIN_REGISTRY" ]
434
466
# Close editor related elements window.editor.close_all_files() # Force close all files while window.editor.editorstacks[0].close_file(force=True): pass for editorwindow in window.editor.editorwindows: editorwindow.close() editorstack = window.editor.get_current_editorstack() if editorstack.switcher_plugin: editorstack.switcher_plugin.on_close() window.projects.close_project() if window.console.error_dialog: window.console.close_error_dialog() # Reset cwd window.explorer.chdir(get_home_dir()) # Restore default Spyder Python Path CONF.set( 'pythonpath_manager', 'spyder_pythonpath', CONF.get_default('pythonpath_manager', 'spyder_pythonpath') ) # Restore run configurations CONF.set('run', 'configurations', [])
conftest.py
spyder.spyder.app.tests
false
false
[ "import os", "import os.path as osp", "import sys", "import threading", "import traceback", "from jupyter_client.manager import KernelManager", "from qtpy.QtCore import Qt", "from qtpy.QtTest import QTest", "from qtpy.QtWidgets import QApplication, QFileDialog, QLineEdit, QTabBar", "from qtpy import QtWebEngineWidgets # noqa", "import psutil", "import pytest", "from spyder.api.plugins import Plugins", "from spyder.app import start", "from spyder.config.base import get_home_dir, running_in_ci", "from spyder.config.manager import CONF", "from spyder.plugins.ipythonconsole.utils.kernelspec import SpyderKernelSpec", "from spyder.plugins.projects.api import EmptyProject", "from spyder.plugins.run.api import RunActions, StoredRunConfigurationExecutor", "from spyder.plugins.toolbar.api import ApplicationToolbars", "from spyder.utils import encoding", "from spyder.utils.environ import (get_user_env, set_user_env,", "from spyder.api.plugin_registration.registry import PLUGIN_REGISTRY" ]
468
496
# Restore run configurations CONF.set('run', 'configurations', []) # Close consoles (window.ipyconsole.get_widget() .create_new_client_if_empty) = False window.ipyconsole.restart() except Exception: main_window.window = None window.close() window = None CONF.reset_to_defaults(notification=False) return if os.name == 'nt': # Do not test leaks on windows return known_leak = request.node.get_closest_marker( 'known_leak') if known_leak: # This test has a known leak return def show_diff(init_list, now_list, name): sys.stderr.write(f"Extra {name} before test:\n") for item in init_list: if item in now_list: now_list.remove(item) else: sys.stderr.write(item + "\n") sys.stderr.write(f"Extra {name} after test:\n") for item in now_list: sys.stderr.write(item + "\n")
conftest.py
spyder.spyder.app.tests
false
true
[ "import os", "import os.path as osp", "import sys", "import threading", "import traceback", "from jupyter_client.manager import KernelManager", "from qtpy.QtCore import Qt", "from qtpy.QtTest import QTest", "from qtpy.QtWidgets import QApplication, QFileDialog, QLineEdit, QTabBar", "from qtpy import QtWebEngineWidgets # noqa", "import psutil", "import pytest", "from spyder.api.plugins import Plugins", "from spyder.app import start", "from spyder.config.base import get_home_dir, running_in_ci", "from spyder.config.manager import CONF", "from spyder.plugins.ipythonconsole.utils.kernelspec import SpyderKernelSpec", "from spyder.plugins.projects.api import EmptyProject", "from spyder.plugins.run.api import RunActions, StoredRunConfigurationExecutor", "from spyder.plugins.toolbar.api import ApplicationToolbars", "from spyder.utils import encoding", "from spyder.utils.environ import (get_user_env, set_user_env,", "from spyder.api.plugin_registration.registry import PLUGIN_REGISTRY" ]
495
528
# The test is not allowed to open new files or threads. try: def threads_condition(): threads = [ thread for thread in threading.enumerate() if not isinstance(thread, threading._DummyThread)] return (len(init_threads) >= len(threads)) qtbot.waitUntil(threads_condition, timeout=SHELL_TIMEOUT) except Exception: now_threads = [ thread for thread in threading.enumerate() if not isinstance(thread, threading._DummyThread)] threads = [repr(t) for t in now_threads] show_diff(init_threads, threads, "thread") sys.stderr.write("Running Threads stacks:\n") now_thread_ids = [t.ident for t in now_threads] for thread_id, frame in sys._current_frames().items(): if thread_id in now_thread_ids: sys.stderr.write( "\nThread " + str(threads) + ":\n") traceback.print_stack(frame) main_window.window = None window.close() window = None CONF.reset_to_defaults(notification=False) raise
conftest.py
spyder.spyder.app.tests
false
true
[ "import os", "import os.path as osp", "import sys", "import threading", "import traceback", "from jupyter_client.manager import KernelManager", "from qtpy.QtCore import Qt", "from qtpy.QtTest import QTest", "from qtpy.QtWidgets import QApplication, QFileDialog, QLineEdit, QTabBar", "from qtpy import QtWebEngineWidgets # noqa", "import psutil", "import pytest", "from spyder.api.plugins import Plugins", "from spyder.app import start", "from spyder.config.base import get_home_dir, running_in_ci", "from spyder.config.manager import CONF", "from spyder.plugins.ipythonconsole.utils.kernelspec import SpyderKernelSpec", "from spyder.plugins.projects.api import EmptyProject", "from spyder.plugins.run.api import RunActions, StoredRunConfigurationExecutor", "from spyder.plugins.toolbar.api import ApplicationToolbars", "from spyder.utils import encoding", "from spyder.utils.environ import (get_user_env, set_user_env,", "from spyder.api.plugin_registration.registry import PLUGIN_REGISTRY" ]
530
556
try: qtbot.waitUntil(lambda: ( len(init_subprocesses) >= len(proc.children())), timeout=SHELL_TIMEOUT) except Exception: subprocesses = [repr(f) for f in proc.children()] show_diff(init_subprocesses, subprocesses, "processes") main_window.window = None window.close() window = None CONF.reset_to_defaults(notification=False) raise try: files = [ repr(f) for f in proc.open_files() if 'QtWebEngine' not in repr(f) ] qtbot.waitUntil( lambda: (len(init_files) >= len(files)), timeout=SHELL_TIMEOUT) except Exception: show_diff(init_files, files, "files") main_window.window = None window.close() window = None CONF.reset_to_defaults(notification=False) raise
conftest.py
spyder.spyder.app.tests
false
false
[ "import os", "import os.path as osp", "import sys", "import threading", "import traceback", "from jupyter_client.manager import KernelManager", "from qtpy.QtCore import Qt", "from qtpy.QtTest import QTest", "from qtpy.QtWidgets import QApplication, QFileDialog, QLineEdit, QTabBar", "from qtpy import QtWebEngineWidgets # noqa", "import psutil", "import pytest", "from spyder.api.plugins import Plugins", "from spyder.app import start", "from spyder.config.base import get_home_dir, running_in_ci", "from spyder.config.manager import CONF", "from spyder.plugins.ipythonconsole.utils.kernelspec import SpyderKernelSpec", "from spyder.plugins.projects.api import EmptyProject", "from spyder.plugins.run.api import RunActions, StoredRunConfigurationExecutor", "from spyder.plugins.toolbar.api import ApplicationToolbars", "from spyder.utils import encoding", "from spyder.utils.environ import (get_user_env, set_user_env,", "from spyder.api.plugin_registration.registry import PLUGIN_REGISTRY" ]
558
585
def restore_user_env(): """Set user environment variables and restore upon test exit""" if not running_in_ci(): pytest.skip("Skipped because not in CI.") if os.name == "nt": orig_env = get_user_env() yield if os.name == "nt": set_user_env(orig_env) else: amend_user_shell_init(restore=True)
conftest.py
spyder.spyder.app.tests
false
true
[ "import os", "import os.path as osp", "import sys", "import threading", "import traceback", "from jupyter_client.manager import KernelManager", "from qtpy.QtCore import Qt", "from qtpy.QtTest import QTest", "from qtpy.QtWidgets import QApplication, QFileDialog, QLineEdit, QTabBar", "from qtpy import QtWebEngineWidgets # noqa", "import psutil", "import pytest", "from spyder.api.plugins import Plugins", "from spyder.app import start", "from spyder.config.base import get_home_dir, running_in_ci", "from spyder.config.manager import CONF", "from spyder.plugins.ipythonconsole.utils.kernelspec import SpyderKernelSpec", "from spyder.plugins.projects.api import EmptyProject", "from spyder.plugins.run.api import RunActions, StoredRunConfigurationExecutor", "from spyder.plugins.toolbar.api import ApplicationToolbars", "from spyder.utils import encoding", "from spyder.utils.environ import (get_user_env, set_user_env,", "from spyder.api.plugin_registration.registry import PLUGIN_REGISTRY" ]
589
602
# -*- coding: utf-8 -*- # ---------------------------------------------------------------------------- # Copyright © Spyder Project Contributors # # Licensed under the terms of the MIT License # ---------------------------------------------------------------------------- # Standard library imports import os import os.path as osp import sys import threading import traceback # Third-party imports from jupyter_client.manager import KernelManager from qtpy.QtCore import Qt from qtpy.QtTest import QTest from qtpy.QtWidgets import QApplication, QFileDialog, QLineEdit, QTabBar # This is required to run our tests in VSCode or Spyder-unittest from qtpy import QtWebEngineWidgets # noqa import psutil import pytest # Spyder imports from spyder.api.plugins import Plugins from spyder.app import start from spyder.config.base import get_home_dir, running_in_ci from spyder.config.manager import CONF from spyder.plugins.ipythonconsole.utils.kernelspec import SpyderKernelSpec from spyder.plugins.projects.api import EmptyProject from spyder.plugins.run.api import RunActions, StoredRunConfigurationExecutor from spyder.plugins.toolbar.api import ApplicationToolbars from spyder.utils import encoding from spyder.utils.environ import (get_user_env, set_user_env, amend_user_shell_init)
conftest.py
spyder.spyder.app.tests
false
false
[ "import os", "import os.path as osp", "import sys", "import threading", "import traceback", "from jupyter_client.manager import KernelManager", "from qtpy.QtCore import Qt", "from qtpy.QtTest import QTest", "from qtpy.QtWidgets import QApplication, QFileDialog, QLineEdit, QTabBar", "from qtpy import QtWebEngineWidgets # noqa", "import psutil", "import pytest", "from spyder.api.plugins import Plugins", "from spyder.app import start", "from spyder.config.base import get_home_dir, running_in_ci", "from spyder.config.manager import CONF", "from spyder.plugins.ipythonconsole.utils.kernelspec import SpyderKernelSpec", "from spyder.plugins.projects.api import EmptyProject", "from spyder.plugins.run.api import RunActions, StoredRunConfigurationExecutor", "from spyder.plugins.toolbar.api import ApplicationToolbars", "from spyder.utils import encoding", "from spyder.utils.environ import (get_user_env, set_user_env,", "from spyder.api.plugin_registration.registry import PLUGIN_REGISTRY" ]
1
36
# ============================================================================= # ---- Constants # ============================================================================= # Location of this file LOCATION = osp.realpath(osp.join(os.getcwd(), osp.dirname(__file__))) # Time to wait until the IPython console is ready to receive input # (in milliseconds) SHELL_TIMEOUT = 40000 if os.name == 'nt' else 20000 # Need longer EVAL_TIMEOUT, because need to cythonize and C compile ".pyx" file # before import and eval it COMPILE_AND_EVAL_TIMEOUT = 30000 # Time to wait for the IPython console to evaluate something (in # milliseconds) EVAL_TIMEOUT = 3000 # Time to wait for the completion services to be up or give a response COMPLETION_TIMEOUT = 30000 # ============================================================================= # ---- Auxiliary functions # ============================================================================= # Code for: def open_file_in_editor(main_window, fname, directory=None): # Code for: def reset_run_code(qtbot, shell, code_editor, nsb): # Code for: def start_new_kernel(startup_timeout=60, kernel_name='python', spykernel=False, # Code for: def find_desired_tab_in_window(tab_name, window): # Code for: def read_asset_file(filename): # Code for: def create_project(tmpdir): # Code for: def create_complex_project(tmpdir): # Code for: def create_namespace_project(tmpdir):
conftest.py
spyder.spyder.app.tests
false
true
[ "import os", "import os.path as osp", "import sys", "import threading", "import traceback", "from jupyter_client.manager import KernelManager", "from qtpy.QtCore import Qt", "from qtpy.QtTest import QTest", "from qtpy.QtWidgets import QApplication, QFileDialog, QLineEdit, QTabBar", "from qtpy import QtWebEngineWidgets # noqa", "import psutil", "import pytest", "from spyder.api.plugins import Plugins", "from spyder.app import start", "from spyder.config.base import get_home_dir, running_in_ci", "from spyder.config.manager import CONF", "from spyder.plugins.ipythonconsole.utils.kernelspec import SpyderKernelSpec", "from spyder.plugins.projects.api import EmptyProject", "from spyder.plugins.run.api import RunActions, StoredRunConfigurationExecutor", "from spyder.plugins.toolbar.api import ApplicationToolbars", "from spyder.utils import encoding", "from spyder.utils.environ import (get_user_env, set_user_env,", "from spyder.api.plugin_registration.registry import PLUGIN_REGISTRY" ]
39
85
# Code for: def read_asset_file(filename): # Code for: def create_project(tmpdir): # Code for: def create_complex_project(tmpdir): # Code for: def create_namespace_project(tmpdir): # Code for: def preferences_dialog_helper(qtbot, main_window, section): # Code for: def generate_run_parameters(mainwindow, filename, selected=None, # ============================================================================= # ---- Pytest hooks # ============================================================================= @pytest.hookimpl(tryfirst=True, hookwrapper=True) # Code for: def pytest_runtest_makereport(item, call): # ============================================================================= # ---- Fixtures # ============================================================================= @pytest.fixture(scope="session", autouse=True) # Code for: def cleanup(request, qapp): @pytest.fixture # Code for: def main_window(request, tmpdir, qtbot): @pytest.fixture # Code for: def restore_user_env():
conftest.py
spyder.spyder.app.tests
false
true
[ "import os", "import os.path as osp", "import sys", "import threading", "import traceback", "from jupyter_client.manager import KernelManager", "from qtpy.QtCore import Qt", "from qtpy.QtTest import QTest", "from qtpy.QtWidgets import QApplication, QFileDialog, QLineEdit, QTabBar", "from qtpy import QtWebEngineWidgets # noqa", "import psutil", "import pytest", "from spyder.api.plugins import Plugins", "from spyder.app import start", "from spyder.config.base import get_home_dir, running_in_ci", "from spyder.config.manager import CONF", "from spyder.plugins.ipythonconsole.utils.kernelspec import SpyderKernelSpec", "from spyder.plugins.projects.api import EmptyProject", "from spyder.plugins.run.api import RunActions, StoredRunConfigurationExecutor", "from spyder.plugins.toolbar.api import ApplicationToolbars", "from spyder.utils import encoding", "from spyder.utils.environ import (get_user_env, set_user_env,", "from spyder.api.plugin_registration.registry import PLUGIN_REGISTRY" ]
-1
-1
# -*- coding: utf-8 -*- # ----------------------------------------------------------------------------- # Copyright (c) Spyder Project Contributors # # Licensed under the terms of the MIT License # (see LICENSE.txt for details) # ----------------------------------------------------------------------------- """Tests."""
__init__.py
spyder.spyder.app.tests
false
false
[]
1
9
# Taken from the following comment: # https://github.com/spyder-ide/spyder/issues/16406#issuecomment-917992317 # # This helps to test a regression for issue spyder-ide/spyder#16406 import logging def some_function(): logging.info('Some message') class SomeClass: def __init__(self): pass def some_method(self): pass
script_outline_4.py
spyder.spyder.app.tests
true
true
[ "import logging" ]
1
18
# -*- coding: utf-8 -*- # # Copyright © Spyder Project Contributors # Licensed under the terms of the MIT License # """ Tests for cli_options.py """ import pytest from spyder.app import cli_options @pytest.mark.order(1)
test_cli_options.py
spyder.spyder.app.tests
false
false
[ "import pytest", "from spyder.app import cli_options" ]
1
14
def test_get_options(): getopt = cli_options.get_options options, args = getopt([]) assert not options.new_instance assert not options.reset_to_defaults assert not options.reset_config_files assert not options.optimize assert not options.paths assert options.working_directory is None assert not options.hide_console assert not options.show_console assert not options.multithreaded assert not options.profile assert options.window_title is None assert options.project is None assert options.opengl_implementation is None assert options.files == [] assert args == [] options, args = getopt(['--new-instance']) assert options.new_instance options, args = getopt(['--defaults', '--reset']) assert options.reset_to_defaults assert options.reset_config_files options, args = getopt(['--optimize', '--workdir', 'test dir']) assert options.optimize assert options.working_directory == 'test dir' options, args = getopt('--window-title MyWindow'.split()) assert options.window_title == 'MyWindow' options, args = getopt('-p myproject test_file.py another_file.py'.split()) assert options.project == 'myproject' assert options.files == ['test_file.py', 'another_file.py'] assert args == ['test_file.py', 'another_file.py'] with pytest.raises(SystemExit): options, args = getopt(['--version'])
test_cli_options.py
spyder.spyder.app.tests
false
true
[ "import pytest", "from spyder.app import cli_options" ]
15
55
with pytest.raises(SystemExit): options, args = getopt(['--version']) # Requires string. with pytest.raises(SystemExit): options, args = getopt(['-w']) # Requires string. with pytest.raises(SystemExit): options, args = getopt(['-p']) options, args = getopt('--opengl software'.split()) assert options.opengl_implementation == 'software' if __name__ == "__main__": pytest.main()
test_cli_options.py
spyder.spyder.app.tests
false
false
[ "import pytest", "from spyder.app import cli_options" ]
54
70
from math import cos from numpy import ( linspace) def foo(x): return x class MyClass: C = 1 def one(self): return 1 def two(self): return 2
script_outline_1.py
spyder.spyder.app.tests
true
true
[ "from math import cos", "from numpy import (" ]
1
15
def test_single_instance_and_edit_magic(main_window, qtbot, tmpdir): """Test single instance mode and %edit magic.""" editorstack = main_window.editor.get_current_editorstack() shell = main_window.ipyconsole.get_current_shellwidget() qtbot.waitUntil( lambda: shell.spyder_kernel_ready and shell._prompt_html is not None, timeout=SHELL_TIMEOUT) spy_dir = osp.dirname(get_module_path('spyder')) lock_code = ( "import sys\n" "sys.path.append(r'{spy_dir_str}')\n" "from spyder.utils.external import lockfile\n" "lock_file = r'{lock_file}'\n" "lock = lockfile.FilesystemLock(lock_file)\n" "lock_created = lock.lock()\n" "print(lock_created)".format( spy_dir_str=spy_dir, lock_file=get_conf_path('spyder.lock')) ) with qtbot.waitSignal(shell.executed, timeout=2000): shell.execute(lock_code) qtbot.wait(1000) assert not shell.get_value('lock_created') # Test %edit magic n_editors = editorstack.get_stack_count() p = tmpdir.mkdir("foo").join("bar.py") p.write(lock_code) with qtbot.waitSignal(shell.executed): shell.execute('%edit {}'.format(to_text_string(p))) qtbot.wait(3000) assert editorstack.get_stack_count() == n_editors + 1 assert editorstack.get_current_editor().toPlainText() == lock_code main_window.editor.close_file()
test_mainwindow.py
spyder.spyder.app.tests
false
true
[ "import gc", "import os", "import os.path as osp", "from pathlib import Path", "import random", "import re", "import shutil", "import sys", "import tempfile", "from textwrap import dedent", "import time", "from unittest.mock import Mock", "import uuid", "from flaky import flaky", "import ipykernel", "from IPython.core import release as ipy_release", "from matplotlib.testing.compare import compare_images", "import nbconvert", "import numpy as np", "from numpy.testing import assert_array_equal", "from packaging.version import parse", "import pylint", "import pytest", "from qtpy import PYQT_VERSION, PYQT5", "from qtpy.QtCore import QPoint, Qt, QTimer", "from qtpy.QtGui import QImage, QTextCursor", "from qtpy.QtWidgets import QAction, QApplication, QInputDialog, QWidget", "from qtpy.QtWebEngineWidgets import WEBENGINE", "from spyder import __trouble_url__", "from spyder.api.utils import get_class_values", "from spyder.api.widgets.auxiliary_widgets import SpyderWindowWidget", "from spyder.api.plugins import Plugins", "from spyder.app.tests.conftest import (", "from spyder.config.base import (", "from spyder.config.manager import CONF", "from spyder.dependencies import DEPENDENCIES", "from spyder.plugins.debugger.api import DebuggerWidgetActions", "from spyder.plugins.externalterminal.api import ExtTerminalShConfiguration", "from spyder.plugins.help.widgets import ObjectComboBox", "from spyder.plugins.help.tests.test_plugin import check_text", "from spyder.plugins.ipythonconsole.utils.kernel_handler import KernelHandler", "from spyder.plugins.ipythonconsole.api import (", "from spyder.plugins.mainmenu.api import ApplicationMenus", "from spyder.plugins.layout.layouts import DefaultLayouts", "from spyder.plugins.toolbar.api import ApplicationToolbars", "from spyder.plugins.run.api import (", "from spyder.py3compat import qbytearray_to_str, to_text_string", "from spyder.utils.environ import set_user_env", "from spyder.utils.misc import remove_backslashes, rename_file", "from spyder.utils.clipboard_helper import CLIPBOARD_HELPER", "from spyder.utils.programs import find_program", "from spyder.widgets.dock import DockTitleBar", "\"import sys\\n\"", "\"from spyder.utils.external import lockfile\\n\"", "shell.execute('import numpy as np; A=np.full(16, np.nan)')", "shell.execute('import numpy as np')", "(\"import numpy as np\", \"An array object of arbitrary homogeneous items\")])", "shell.execute('import os; current_dir = os.getcwd()')", "shell.execute('import os; current_dir = os.getcwd()')", "shell.execute(\"import sys; import os; \"", "shell.execute(\"import sys; import os; \"", "qtbot.keyClicks(control, 'import os; os.getcwd()')", "shell.execute((\"import matplotlib.pyplot as plt\\n\"", "shell.execute((\"import matplotlib.pyplot as plt\\n\"", "\"import time\\n\"", "shell.execute((\"import matplotlib.pyplot as plt\\n\"", "shell.execute((\"import matplotlib.pyplot as plt\\n\"", "from spyder.widgets.collectionseditor import CollectionsEditor", "from spyder.plugins.pylint.main_widget import PylintWidgetActions", "shell.execute('def foo(): import foo')", "code = (\"import time\\n\"", "from qtpy.QtCore import Qt", "code_def = \"import qtpy.QtCore\"", "shell.execute(\"import time\\n\"", "code = (\"import time\\n\"", "cmd = 'import sys;print(sys.path)'", "code2 = (\"from tmp import a\\n\"", "code2 = (\"from tmp import a\\n\"", "'import time\\n'", "'import time\\n'", "'from file1 import f\\n'", "text = (\"import multiprocessing\\n\"", "\"import traceback\\n\"", "text = (\"import multiprocessing\\n\"", "\"import traceback\\n\"", "import multiprocessing", "import sys", "import ctypes; ctypes.string_at(0)", "\"import threading\\n\"", "'import threading\\n'", "import pprint", "shell.execute(\"import ctypes; ctypes.string_at(0)\")", "shell.execute('import time')", "shell.execute('import time')", "shell.execute(\"import sys; sys_path = sys.path\")", "shell1.execute(\"import sys; sys_path = sys.path\")", "s.execute(\"import sys; sys_path = sys.path\")" ]
87
125
def test_leaks(main_window, qtbot): """ Test leaks in mainwindow when closing a file or a console. Many other ways of leaking exist but are not covered here. """ def ns_fun(main_window, qtbot): # Wait until the window is fully up shell = main_window.ipyconsole.get_current_shellwidget() qtbot.waitUntil( lambda: ( shell.spyder_kernel_ready and shell._prompt_html is not None ), timeout=SHELL_TIMEOUT) # Count initial objects # Only one of each should be present, but because of many leaks, # this is most likely not the case. Here only closing is tested KernelHandler.wait_all_shutdown_threads() gc.collect() objects = gc.get_objects() n_code_editor_init = 0 for o in objects: if type(o).__name__ == "CodeEditor": n_code_editor_init += 1 n_shell_init = 0 for o in objects: if type(o).__name__ == "ShellWidget": n_shell_init += 1 # Open a second file and console main_window.editor.new() main_window.ipyconsole.create_new_client() # Do something interesting in the new window code_editor = main_window.editor.get_focus_widget() # Show an error in the editor code_editor.set_text("aaa")
test_mainwindow.py
spyder.spyder.app.tests
false
true
[ "import gc", "import os", "import os.path as osp", "from pathlib import Path", "import random", "import re", "import shutil", "import sys", "import tempfile", "from textwrap import dedent", "import time", "from unittest.mock import Mock", "import uuid", "from flaky import flaky", "import ipykernel", "from IPython.core import release as ipy_release", "from matplotlib.testing.compare import compare_images", "import nbconvert", "import numpy as np", "from numpy.testing import assert_array_equal", "from packaging.version import parse", "import pylint", "import pytest", "from qtpy import PYQT_VERSION, PYQT5", "from qtpy.QtCore import QPoint, Qt, QTimer", "from qtpy.QtGui import QImage, QTextCursor", "from qtpy.QtWidgets import QAction, QApplication, QInputDialog, QWidget", "from qtpy.QtWebEngineWidgets import WEBENGINE", "from spyder import __trouble_url__", "from spyder.api.utils import get_class_values", "from spyder.api.widgets.auxiliary_widgets import SpyderWindowWidget", "from spyder.api.plugins import Plugins", "from spyder.app.tests.conftest import (", "from spyder.config.base import (", "from spyder.config.manager import CONF", "from spyder.dependencies import DEPENDENCIES", "from spyder.plugins.debugger.api import DebuggerWidgetActions", "from spyder.plugins.externalterminal.api import ExtTerminalShConfiguration", "from spyder.plugins.help.widgets import ObjectComboBox", "from spyder.plugins.help.tests.test_plugin import check_text", "from spyder.plugins.ipythonconsole.utils.kernel_handler import KernelHandler", "from spyder.plugins.ipythonconsole.api import (", "from spyder.plugins.mainmenu.api import ApplicationMenus", "from spyder.plugins.layout.layouts import DefaultLayouts", "from spyder.plugins.toolbar.api import ApplicationToolbars", "from spyder.plugins.run.api import (", "from spyder.py3compat import qbytearray_to_str, to_text_string", "from spyder.utils.environ import set_user_env", "from spyder.utils.misc import remove_backslashes, rename_file", "from spyder.utils.clipboard_helper import CLIPBOARD_HELPER", "from spyder.utils.programs import find_program", "from spyder.widgets.dock import DockTitleBar", "\"import sys\\n\"", "\"from spyder.utils.external import lockfile\\n\"", "shell.execute('import numpy as np; A=np.full(16, np.nan)')", "shell.execute('import numpy as np')", "(\"import numpy as np\", \"An array object of arbitrary homogeneous items\")])", "shell.execute('import os; current_dir = os.getcwd()')", "shell.execute('import os; current_dir = os.getcwd()')", "shell.execute(\"import sys; import os; \"", "shell.execute(\"import sys; import os; \"", "qtbot.keyClicks(control, 'import os; os.getcwd()')", "shell.execute((\"import matplotlib.pyplot as plt\\n\"", "shell.execute((\"import matplotlib.pyplot as plt\\n\"", "\"import time\\n\"", "shell.execute((\"import matplotlib.pyplot as plt\\n\"", "shell.execute((\"import matplotlib.pyplot as plt\\n\"", "from spyder.widgets.collectionseditor import CollectionsEditor", "from spyder.plugins.pylint.main_widget import PylintWidgetActions", "shell.execute('def foo(): import foo')", "code = (\"import time\\n\"", "from qtpy.QtCore import Qt", "code_def = \"import qtpy.QtCore\"", "shell.execute(\"import time\\n\"", "code = (\"import time\\n\"", "cmd = 'import sys;print(sys.path)'", "code2 = (\"from tmp import a\\n\"", "code2 = (\"from tmp import a\\n\"", "'import time\\n'", "'import time\\n'", "'from file1 import f\\n'", "text = (\"import multiprocessing\\n\"", "\"import traceback\\n\"", "text = (\"import multiprocessing\\n\"", "\"import traceback\\n\"", "import multiprocessing", "import sys", "import ctypes; ctypes.string_at(0)", "\"import threading\\n\"", "'import threading\\n'", "import pprint", "shell.execute(\"import ctypes; ctypes.string_at(0)\")", "shell.execute('import time')", "shell.execute('import time')", "shell.execute(\"import sys; sys_path = sys.path\")", "shell1.execute(\"import sys; sys_path = sys.path\")", "s.execute(\"import sys; sys_path = sys.path\")" ]
130
168
shell = main_window.ipyconsole.get_current_shellwidget() qtbot.waitUntil( lambda: ( shell.spyder_kernel_ready and shell._prompt_html is not None ), timeout=SHELL_TIMEOUT) with qtbot.waitSignal(shell.executed): shell.execute("%debug print()") # Close all files and consoles main_window.editor.close_all_files() main_window.ipyconsole.restart() # Wait until the shells are closed KernelHandler.wait_all_shutdown_threads() return n_shell_init, n_code_editor_init n_shell_init, n_code_editor_init = ns_fun(main_window, qtbot) qtbot.wait(1000) # Count final objects gc.collect() objects = gc.get_objects() n_code_editor = 0 for o in objects: if type(o).__name__ == "CodeEditor": n_code_editor += 1 n_shell = 0 for o in objects: if type(o).__name__ == "ShellWidget": n_shell += 1 # Make sure no new objects have been created assert n_shell <= n_shell_init assert n_code_editor <= n_code_editor_init
test_mainwindow.py
spyder.spyder.app.tests
false
false
[ "import gc", "import os", "import os.path as osp", "from pathlib import Path", "import random", "import re", "import shutil", "import sys", "import tempfile", "from textwrap import dedent", "import time", "from unittest.mock import Mock", "import uuid", "from flaky import flaky", "import ipykernel", "from IPython.core import release as ipy_release", "from matplotlib.testing.compare import compare_images", "import nbconvert", "import numpy as np", "from numpy.testing import assert_array_equal", "from packaging.version import parse", "import pylint", "import pytest", "from qtpy import PYQT_VERSION, PYQT5", "from qtpy.QtCore import QPoint, Qt, QTimer", "from qtpy.QtGui import QImage, QTextCursor", "from qtpy.QtWidgets import QAction, QApplication, QInputDialog, QWidget", "from qtpy.QtWebEngineWidgets import WEBENGINE", "from spyder import __trouble_url__", "from spyder.api.utils import get_class_values", "from spyder.api.widgets.auxiliary_widgets import SpyderWindowWidget", "from spyder.api.plugins import Plugins", "from spyder.app.tests.conftest import (", "from spyder.config.base import (", "from spyder.config.manager import CONF", "from spyder.dependencies import DEPENDENCIES", "from spyder.plugins.debugger.api import DebuggerWidgetActions", "from spyder.plugins.externalterminal.api import ExtTerminalShConfiguration", "from spyder.plugins.help.widgets import ObjectComboBox", "from spyder.plugins.help.tests.test_plugin import check_text", "from spyder.plugins.ipythonconsole.utils.kernel_handler import KernelHandler", "from spyder.plugins.ipythonconsole.api import (", "from spyder.plugins.mainmenu.api import ApplicationMenus", "from spyder.plugins.layout.layouts import DefaultLayouts", "from spyder.plugins.toolbar.api import ApplicationToolbars", "from spyder.plugins.run.api import (", "from spyder.py3compat import qbytearray_to_str, to_text_string", "from spyder.utils.environ import set_user_env", "from spyder.utils.misc import remove_backslashes, rename_file", "from spyder.utils.clipboard_helper import CLIPBOARD_HELPER", "from spyder.utils.programs import find_program", "from spyder.widgets.dock import DockTitleBar", "\"import sys\\n\"", "\"from spyder.utils.external import lockfile\\n\"", "shell.execute('import numpy as np; A=np.full(16, np.nan)')", "shell.execute('import numpy as np')", "(\"import numpy as np\", \"An array object of arbitrary homogeneous items\")])", "shell.execute('import os; current_dir = os.getcwd()')", "shell.execute('import os; current_dir = os.getcwd()')", "shell.execute(\"import sys; import os; \"", "shell.execute(\"import sys; import os; \"", "qtbot.keyClicks(control, 'import os; os.getcwd()')", "shell.execute((\"import matplotlib.pyplot as plt\\n\"", "shell.execute((\"import matplotlib.pyplot as plt\\n\"", "\"import time\\n\"", "shell.execute((\"import matplotlib.pyplot as plt\\n\"", "shell.execute((\"import matplotlib.pyplot as plt\\n\"", "from spyder.widgets.collectionseditor import CollectionsEditor", "from spyder.plugins.pylint.main_widget import PylintWidgetActions", "shell.execute('def foo(): import foo')", "code = (\"import time\\n\"", "from qtpy.QtCore import Qt", "code_def = \"import qtpy.QtCore\"", "shell.execute(\"import time\\n\"", "code = (\"import time\\n\"", "cmd = 'import sys;print(sys.path)'", "code2 = (\"from tmp import a\\n\"", "code2 = (\"from tmp import a\\n\"", "'import time\\n'", "'import time\\n'", "'from file1 import f\\n'", "text = (\"import multiprocessing\\n\"", "\"import traceback\\n\"", "text = (\"import multiprocessing\\n\"", "\"import traceback\\n\"", "import multiprocessing", "import sys", "import ctypes; ctypes.string_at(0)", "\"import threading\\n\"", "'import threading\\n'", "import pprint", "shell.execute(\"import ctypes; ctypes.string_at(0)\")", "shell.execute('import time')", "shell.execute('import time')", "shell.execute(\"import sys; sys_path = sys.path\")", "shell1.execute(\"import sys; sys_path = sys.path\")", "s.execute(\"import sys; sys_path = sys.path\")" ]
90
124
def test_lock_action(main_window, qtbot): """Test the lock interface action.""" # Wait until the window is fully up shell = main_window.ipyconsole.get_current_shellwidget() qtbot.waitUntil( lambda: shell.spyder_kernel_ready and shell._prompt_html is not None, timeout=SHELL_TIMEOUT) action = main_window.layouts.lock_interface_action plugins = main_window.widgetlist # By default the interface is locked. assert main_window.layouts._interface_locked # In this state the title bar is an empty QWidget for plugin in plugins: title_bar = plugin.dockwidget.titleBarWidget() assert not isinstance(title_bar, DockTitleBar) assert isinstance(title_bar, QWidget) # Test that our custom title bar is shown when the action # is triggered. action.trigger() for plugin in plugins: title_bar = plugin.dockwidget.titleBarWidget() assert isinstance(title_bar, DockTitleBar) assert not main_window.layouts._interface_locked # Restore default state action.trigger() assert main_window.layouts._interface_locked
test_mainwindow.py
spyder.spyder.app.tests
false
true
[ "import gc", "import os", "import os.path as osp", "from pathlib import Path", "import random", "import re", "import shutil", "import sys", "import tempfile", "from textwrap import dedent", "import time", "from unittest.mock import Mock", "import uuid", "from flaky import flaky", "import ipykernel", "from IPython.core import release as ipy_release", "from matplotlib.testing.compare import compare_images", "import nbconvert", "import numpy as np", "from numpy.testing import assert_array_equal", "from packaging.version import parse", "import pylint", "import pytest", "from qtpy import PYQT_VERSION, PYQT5", "from qtpy.QtCore import QPoint, Qt, QTimer", "from qtpy.QtGui import QImage, QTextCursor", "from qtpy.QtWidgets import QAction, QApplication, QInputDialog, QWidget", "from qtpy.QtWebEngineWidgets import WEBENGINE", "from spyder import __trouble_url__", "from spyder.api.utils import get_class_values", "from spyder.api.widgets.auxiliary_widgets import SpyderWindowWidget", "from spyder.api.plugins import Plugins", "from spyder.app.tests.conftest import (", "from spyder.config.base import (", "from spyder.config.manager import CONF", "from spyder.dependencies import DEPENDENCIES", "from spyder.plugins.debugger.api import DebuggerWidgetActions", "from spyder.plugins.externalterminal.api import ExtTerminalShConfiguration", "from spyder.plugins.help.widgets import ObjectComboBox", "from spyder.plugins.help.tests.test_plugin import check_text", "from spyder.plugins.ipythonconsole.utils.kernel_handler import KernelHandler", "from spyder.plugins.ipythonconsole.api import (", "from spyder.plugins.mainmenu.api import ApplicationMenus", "from spyder.plugins.layout.layouts import DefaultLayouts", "from spyder.plugins.toolbar.api import ApplicationToolbars", "from spyder.plugins.run.api import (", "from spyder.py3compat import qbytearray_to_str, to_text_string", "from spyder.utils.environ import set_user_env", "from spyder.utils.misc import remove_backslashes, rename_file", "from spyder.utils.clipboard_helper import CLIPBOARD_HELPER", "from spyder.utils.programs import find_program", "from spyder.widgets.dock import DockTitleBar", "\"import sys\\n\"", "\"from spyder.utils.external import lockfile\\n\"", "shell.execute('import numpy as np; A=np.full(16, np.nan)')", "shell.execute('import numpy as np')", "(\"import numpy as np\", \"An array object of arbitrary homogeneous items\")])", "shell.execute('import os; current_dir = os.getcwd()')", "shell.execute('import os; current_dir = os.getcwd()')", "shell.execute(\"import sys; import os; \"", "shell.execute(\"import sys; import os; \"", "qtbot.keyClicks(control, 'import os; os.getcwd()')", "shell.execute((\"import matplotlib.pyplot as plt\\n\"", "shell.execute((\"import matplotlib.pyplot as plt\\n\"", "\"import time\\n\"", "shell.execute((\"import matplotlib.pyplot as plt\\n\"", "shell.execute((\"import matplotlib.pyplot as plt\\n\"", "from spyder.widgets.collectionseditor import CollectionsEditor", "from spyder.plugins.pylint.main_widget import PylintWidgetActions", "shell.execute('def foo(): import foo')", "code = (\"import time\\n\"", "from qtpy.QtCore import Qt", "code_def = \"import qtpy.QtCore\"", "shell.execute(\"import time\\n\"", "code = (\"import time\\n\"", "cmd = 'import sys;print(sys.path)'", "code2 = (\"from tmp import a\\n\"", "code2 = (\"from tmp import a\\n\"", "'import time\\n'", "'import time\\n'", "'from file1 import f\\n'", "text = (\"import multiprocessing\\n\"", "\"import traceback\\n\"", "text = (\"import multiprocessing\\n\"", "\"import traceback\\n\"", "import multiprocessing", "import sys", "import ctypes; ctypes.string_at(0)", "\"import threading\\n\"", "'import threading\\n'", "import pprint", "shell.execute(\"import ctypes; ctypes.string_at(0)\")", "shell.execute('import time')", "shell.execute('import time')", "shell.execute(\"import sys; sys_path = sys.path\")", "shell1.execute(\"import sys; sys_path = sys.path\")", "s.execute(\"import sys; sys_path = sys.path\")" ]
207
237
def test_default_plugin_actions(main_window, qtbot): """Test the effect of dock, undock, close and toggle view actions.""" # Wait until the window is fully up shell = main_window.ipyconsole.get_current_shellwidget() qtbot.waitUntil( lambda: shell.spyder_kernel_ready and shell._prompt_html is not None, timeout=SHELL_TIMEOUT) # Use a particular plugin file_explorer = main_window.explorer main_widget = file_explorer.get_widget() # Undock action main_widget.undock_action.triggered.emit(True) qtbot.wait(500) main_widget.windowwidget.move(200, 200) assert not file_explorer.dockwidget.isVisible() assert main_widget.undock_action is not None assert isinstance(main_widget.windowwidget, SpyderWindowWidget) assert main_widget.windowwidget.centralWidget() == main_widget # Dock action main_widget.dock_action.triggered.emit(True) qtbot.wait(500) assert file_explorer.dockwidget.isVisible() assert main_widget.windowwidget is None # Test geometry was saved on close geometry = file_explorer.get_conf('window_geometry') assert geometry != '' # Test restoring undocked plugin with the right geometry file_explorer.set_conf('undocked_on_window_close', True) main_window.restore_undocked_plugins() assert main_widget.windowwidget is not None assert ( geometry == qbytearray_to_str(main_widget.windowwidget.saveGeometry()) ) main_widget.windowwidget.close()
test_mainwindow.py
spyder.spyder.app.tests
false
true
[ "import gc", "import os", "import os.path as osp", "from pathlib import Path", "import random", "import re", "import shutil", "import sys", "import tempfile", "from textwrap import dedent", "import time", "from unittest.mock import Mock", "import uuid", "from flaky import flaky", "import ipykernel", "from IPython.core import release as ipy_release", "from matplotlib.testing.compare import compare_images", "import nbconvert", "import numpy as np", "from numpy.testing import assert_array_equal", "from packaging.version import parse", "import pylint", "import pytest", "from qtpy import PYQT_VERSION, PYQT5", "from qtpy.QtCore import QPoint, Qt, QTimer", "from qtpy.QtGui import QImage, QTextCursor", "from qtpy.QtWidgets import QAction, QApplication, QInputDialog, QWidget", "from qtpy.QtWebEngineWidgets import WEBENGINE", "from spyder import __trouble_url__", "from spyder.api.utils import get_class_values", "from spyder.api.widgets.auxiliary_widgets import SpyderWindowWidget", "from spyder.api.plugins import Plugins", "from spyder.app.tests.conftest import (", "from spyder.config.base import (", "from spyder.config.manager import CONF", "from spyder.dependencies import DEPENDENCIES", "from spyder.plugins.debugger.api import DebuggerWidgetActions", "from spyder.plugins.externalterminal.api import ExtTerminalShConfiguration", "from spyder.plugins.help.widgets import ObjectComboBox", "from spyder.plugins.help.tests.test_plugin import check_text", "from spyder.plugins.ipythonconsole.utils.kernel_handler import KernelHandler", "from spyder.plugins.ipythonconsole.api import (", "from spyder.plugins.mainmenu.api import ApplicationMenus", "from spyder.plugins.layout.layouts import DefaultLayouts", "from spyder.plugins.toolbar.api import ApplicationToolbars", "from spyder.plugins.run.api import (", "from spyder.py3compat import qbytearray_to_str, to_text_string", "from spyder.utils.environ import set_user_env", "from spyder.utils.misc import remove_backslashes, rename_file", "from spyder.utils.clipboard_helper import CLIPBOARD_HELPER", "from spyder.utils.programs import find_program", "from spyder.widgets.dock import DockTitleBar", "\"import sys\\n\"", "\"from spyder.utils.external import lockfile\\n\"", "shell.execute('import numpy as np; A=np.full(16, np.nan)')", "shell.execute('import numpy as np')", "(\"import numpy as np\", \"An array object of arbitrary homogeneous items\")])", "shell.execute('import os; current_dir = os.getcwd()')", "shell.execute('import os; current_dir = os.getcwd()')", "shell.execute(\"import sys; import os; \"", "shell.execute(\"import sys; import os; \"", "qtbot.keyClicks(control, 'import os; os.getcwd()')", "shell.execute((\"import matplotlib.pyplot as plt\\n\"", "shell.execute((\"import matplotlib.pyplot as plt\\n\"", "\"import time\\n\"", "shell.execute((\"import matplotlib.pyplot as plt\\n\"", "shell.execute((\"import matplotlib.pyplot as plt\\n\"", "from spyder.widgets.collectionseditor import CollectionsEditor", "from spyder.plugins.pylint.main_widget import PylintWidgetActions", "shell.execute('def foo(): import foo')", "code = (\"import time\\n\"", "from qtpy.QtCore import Qt", "code_def = \"import qtpy.QtCore\"", "shell.execute(\"import time\\n\"", "code = (\"import time\\n\"", "cmd = 'import sys;print(sys.path)'", "code2 = (\"from tmp import a\\n\"", "code2 = (\"from tmp import a\\n\"", "'import time\\n'", "'import time\\n'", "'from file1 import f\\n'", "text = (\"import multiprocessing\\n\"", "\"import traceback\\n\"", "text = (\"import multiprocessing\\n\"", "\"import traceback\\n\"", "import multiprocessing", "import sys", "import ctypes; ctypes.string_at(0)", "\"import threading\\n\"", "'import threading\\n'", "import pprint", "shell.execute(\"import ctypes; ctypes.string_at(0)\")", "shell.execute('import time')", "shell.execute('import time')", "shell.execute(\"import sys; sys_path = sys.path\")", "shell1.execute(\"import sys; sys_path = sys.path\")", "s.execute(\"import sys; sys_path = sys.path\")" ]
245
283
# Close action main_widget.close_action.triggered.emit(True) qtbot.wait(500) assert not file_explorer.dockwidget.isVisible() assert not file_explorer.toggle_view_action.isChecked() # Toggle view action file_explorer.toggle_view_action.setChecked(True) assert file_explorer.dockwidget.isVisible()
test_mainwindow.py
spyder.spyder.app.tests
false
false
[ "import gc", "import os", "import os.path as osp", "from pathlib import Path", "import random", "import re", "import shutil", "import sys", "import tempfile", "from textwrap import dedent", "import time", "from unittest.mock import Mock", "import uuid", "from flaky import flaky", "import ipykernel", "from IPython.core import release as ipy_release", "from matplotlib.testing.compare import compare_images", "import nbconvert", "import numpy as np", "from numpy.testing import assert_array_equal", "from packaging.version import parse", "import pylint", "import pytest", "from qtpy import PYQT_VERSION, PYQT5", "from qtpy.QtCore import QPoint, Qt, QTimer", "from qtpy.QtGui import QImage, QTextCursor", "from qtpy.QtWidgets import QAction, QApplication, QInputDialog, QWidget", "from qtpy.QtWebEngineWidgets import WEBENGINE", "from spyder import __trouble_url__", "from spyder.api.utils import get_class_values", "from spyder.api.widgets.auxiliary_widgets import SpyderWindowWidget", "from spyder.api.plugins import Plugins", "from spyder.app.tests.conftest import (", "from spyder.config.base import (", "from spyder.config.manager import CONF", "from spyder.dependencies import DEPENDENCIES", "from spyder.plugins.debugger.api import DebuggerWidgetActions", "from spyder.plugins.externalterminal.api import ExtTerminalShConfiguration", "from spyder.plugins.help.widgets import ObjectComboBox", "from spyder.plugins.help.tests.test_plugin import check_text", "from spyder.plugins.ipythonconsole.utils.kernel_handler import KernelHandler", "from spyder.plugins.ipythonconsole.api import (", "from spyder.plugins.mainmenu.api import ApplicationMenus", "from spyder.plugins.layout.layouts import DefaultLayouts", "from spyder.plugins.toolbar.api import ApplicationToolbars", "from spyder.plugins.run.api import (", "from spyder.py3compat import qbytearray_to_str, to_text_string", "from spyder.utils.environ import set_user_env", "from spyder.utils.misc import remove_backslashes, rename_file", "from spyder.utils.clipboard_helper import CLIPBOARD_HELPER", "from spyder.utils.programs import find_program", "from spyder.widgets.dock import DockTitleBar", "\"import sys\\n\"", "\"from spyder.utils.external import lockfile\\n\"", "shell.execute('import numpy as np; A=np.full(16, np.nan)')", "shell.execute('import numpy as np')", "(\"import numpy as np\", \"An array object of arbitrary homogeneous items\")])", "shell.execute('import os; current_dir = os.getcwd()')", "shell.execute('import os; current_dir = os.getcwd()')", "shell.execute(\"import sys; import os; \"", "shell.execute(\"import sys; import os; \"", "qtbot.keyClicks(control, 'import os; os.getcwd()')", "shell.execute((\"import matplotlib.pyplot as plt\\n\"", "shell.execute((\"import matplotlib.pyplot as plt\\n\"", "\"import time\\n\"", "shell.execute((\"import matplotlib.pyplot as plt\\n\"", "shell.execute((\"import matplotlib.pyplot as plt\\n\"", "from spyder.widgets.collectionseditor import CollectionsEditor", "from spyder.plugins.pylint.main_widget import PylintWidgetActions", "shell.execute('def foo(): import foo')", "code = (\"import time\\n\"", "from qtpy.QtCore import Qt", "code_def = \"import qtpy.QtCore\"", "shell.execute(\"import time\\n\"", "code = (\"import time\\n\"", "cmd = 'import sys;print(sys.path)'", "code2 = (\"from tmp import a\\n\"", "code2 = (\"from tmp import a\\n\"", "'import time\\n'", "'import time\\n'", "'from file1 import f\\n'", "text = (\"import multiprocessing\\n\"", "\"import traceback\\n\"", "text = (\"import multiprocessing\\n\"", "\"import traceback\\n\"", "import multiprocessing", "import sys", "import ctypes; ctypes.string_at(0)", "\"import threading\\n\"", "'import threading\\n'", "import pprint", "shell.execute(\"import ctypes; ctypes.string_at(0)\")", "shell.execute('import time')", "shell.execute('import time')", "shell.execute(\"import sys; sys_path = sys.path\")", "shell1.execute(\"import sys; sys_path = sys.path\")", "s.execute(\"import sys; sys_path = sys.path\")" ]
285
293
def test_opengl_implementation(main_window, qtbot): """ Test that we are setting the selected OpenGL implementation """ # Wait until the window is fully up shell = main_window.ipyconsole.get_current_shellwidget() qtbot.waitUntil( lambda: shell.spyder_kernel_ready and shell._prompt_html is not None, timeout=SHELL_TIMEOUT) assert main_window._test_setting_opengl('software') # Restore default config value CONF.set('main', 'opengl', 'automatic')
test_mainwindow.py
spyder.spyder.app.tests
false
true
[ "import gc", "import os", "import os.path as osp", "from pathlib import Path", "import random", "import re", "import shutil", "import sys", "import tempfile", "from textwrap import dedent", "import time", "from unittest.mock import Mock", "import uuid", "from flaky import flaky", "import ipykernel", "from IPython.core import release as ipy_release", "from matplotlib.testing.compare import compare_images", "import nbconvert", "import numpy as np", "from numpy.testing import assert_array_equal", "from packaging.version import parse", "import pylint", "import pytest", "from qtpy import PYQT_VERSION, PYQT5", "from qtpy.QtCore import QPoint, Qt, QTimer", "from qtpy.QtGui import QImage, QTextCursor", "from qtpy.QtWidgets import QAction, QApplication, QInputDialog, QWidget", "from qtpy.QtWebEngineWidgets import WEBENGINE", "from spyder import __trouble_url__", "from spyder.api.utils import get_class_values", "from spyder.api.widgets.auxiliary_widgets import SpyderWindowWidget", "from spyder.api.plugins import Plugins", "from spyder.app.tests.conftest import (", "from spyder.config.base import (", "from spyder.config.manager import CONF", "from spyder.dependencies import DEPENDENCIES", "from spyder.plugins.debugger.api import DebuggerWidgetActions", "from spyder.plugins.externalterminal.api import ExtTerminalShConfiguration", "from spyder.plugins.help.widgets import ObjectComboBox", "from spyder.plugins.help.tests.test_plugin import check_text", "from spyder.plugins.ipythonconsole.utils.kernel_handler import KernelHandler", "from spyder.plugins.ipythonconsole.api import (", "from spyder.plugins.mainmenu.api import ApplicationMenus", "from spyder.plugins.layout.layouts import DefaultLayouts", "from spyder.plugins.toolbar.api import ApplicationToolbars", "from spyder.plugins.run.api import (", "from spyder.py3compat import qbytearray_to_str, to_text_string", "from spyder.utils.environ import set_user_env", "from spyder.utils.misc import remove_backslashes, rename_file", "from spyder.utils.clipboard_helper import CLIPBOARD_HELPER", "from spyder.utils.programs import find_program", "from spyder.widgets.dock import DockTitleBar", "\"import sys\\n\"", "\"from spyder.utils.external import lockfile\\n\"", "shell.execute('import numpy as np; A=np.full(16, np.nan)')", "shell.execute('import numpy as np')", "(\"import numpy as np\", \"An array object of arbitrary homogeneous items\")])", "shell.execute('import os; current_dir = os.getcwd()')", "shell.execute('import os; current_dir = os.getcwd()')", "shell.execute(\"import sys; import os; \"", "shell.execute(\"import sys; import os; \"", "qtbot.keyClicks(control, 'import os; os.getcwd()')", "shell.execute((\"import matplotlib.pyplot as plt\\n\"", "shell.execute((\"import matplotlib.pyplot as plt\\n\"", "\"import time\\n\"", "shell.execute((\"import matplotlib.pyplot as plt\\n\"", "shell.execute((\"import matplotlib.pyplot as plt\\n\"", "from spyder.widgets.collectionseditor import CollectionsEditor", "from spyder.plugins.pylint.main_widget import PylintWidgetActions", "shell.execute('def foo(): import foo')", "code = (\"import time\\n\"", "from qtpy.QtCore import Qt", "code_def = \"import qtpy.QtCore\"", "shell.execute(\"import time\\n\"", "code = (\"import time\\n\"", "cmd = 'import sys;print(sys.path)'", "code2 = (\"from tmp import a\\n\"", "code2 = (\"from tmp import a\\n\"", "'import time\\n'", "'import time\\n'", "'from file1 import f\\n'", "text = (\"import multiprocessing\\n\"", "\"import traceback\\n\"", "text = (\"import multiprocessing\\n\"", "\"import traceback\\n\"", "import multiprocessing", "import sys", "import ctypes; ctypes.string_at(0)", "\"import threading\\n\"", "'import threading\\n'", "import pprint", "shell.execute(\"import ctypes; ctypes.string_at(0)\")", "shell.execute('import time')", "shell.execute('import time')", "shell.execute(\"import sys; sys_path = sys.path\")", "shell1.execute(\"import sys; sys_path = sys.path\")", "s.execute(\"import sys; sys_path = sys.path\")" ]
301
314
def test_filter_numpy_warning(main_window, qtbot): """ Test that we filter a warning shown when an array contains nan values and the Variable Explorer option 'Show arrays min/man' is on. For spyder-ide/spyder#7063. """ shell = main_window.ipyconsole.get_current_shellwidget() control = shell._control qtbot.waitUntil( lambda: shell.spyder_kernel_ready and shell._prompt_html is not None, timeout=SHELL_TIMEOUT) # Create an array with a nan value with qtbot.waitSignal(shell.executed): shell.execute('import numpy as np; A=np.full(16, np.nan)') qtbot.wait(1000) # Assert that no warnings are shown in the console assert "warning" not in control.toPlainText() assert "Warning" not in control.toPlainText() # Restore default config value CONF.set('variable_explorer', 'minmax', False)
test_mainwindow.py
spyder.spyder.app.tests
false
true
[ "import gc", "import os", "import os.path as osp", "from pathlib import Path", "import random", "import re", "import shutil", "import sys", "import tempfile", "from textwrap import dedent", "import time", "from unittest.mock import Mock", "import uuid", "from flaky import flaky", "import ipykernel", "from IPython.core import release as ipy_release", "from matplotlib.testing.compare import compare_images", "import nbconvert", "import numpy as np", "from numpy.testing import assert_array_equal", "from packaging.version import parse", "import pylint", "import pytest", "from qtpy import PYQT_VERSION, PYQT5", "from qtpy.QtCore import QPoint, Qt, QTimer", "from qtpy.QtGui import QImage, QTextCursor", "from qtpy.QtWidgets import QAction, QApplication, QInputDialog, QWidget", "from qtpy.QtWebEngineWidgets import WEBENGINE", "from spyder import __trouble_url__", "from spyder.api.utils import get_class_values", "from spyder.api.widgets.auxiliary_widgets import SpyderWindowWidget", "from spyder.api.plugins import Plugins", "from spyder.app.tests.conftest import (", "from spyder.config.base import (", "from spyder.config.manager import CONF", "from spyder.dependencies import DEPENDENCIES", "from spyder.plugins.debugger.api import DebuggerWidgetActions", "from spyder.plugins.externalterminal.api import ExtTerminalShConfiguration", "from spyder.plugins.help.widgets import ObjectComboBox", "from spyder.plugins.help.tests.test_plugin import check_text", "from spyder.plugins.ipythonconsole.utils.kernel_handler import KernelHandler", "from spyder.plugins.ipythonconsole.api import (", "from spyder.plugins.mainmenu.api import ApplicationMenus", "from spyder.plugins.layout.layouts import DefaultLayouts", "from spyder.plugins.toolbar.api import ApplicationToolbars", "from spyder.plugins.run.api import (", "from spyder.py3compat import qbytearray_to_str, to_text_string", "from spyder.utils.environ import set_user_env", "from spyder.utils.misc import remove_backslashes, rename_file", "from spyder.utils.clipboard_helper import CLIPBOARD_HELPER", "from spyder.utils.programs import find_program", "from spyder.widgets.dock import DockTitleBar", "\"import sys\\n\"", "\"from spyder.utils.external import lockfile\\n\"", "shell.execute('import numpy as np; A=np.full(16, np.nan)')", "shell.execute('import numpy as np')", "(\"import numpy as np\", \"An array object of arbitrary homogeneous items\")])", "shell.execute('import os; current_dir = os.getcwd()')", "shell.execute('import os; current_dir = os.getcwd()')", "shell.execute(\"import sys; import os; \"", "shell.execute(\"import sys; import os; \"", "qtbot.keyClicks(control, 'import os; os.getcwd()')", "shell.execute((\"import matplotlib.pyplot as plt\\n\"", "shell.execute((\"import matplotlib.pyplot as plt\\n\"", "\"import time\\n\"", "shell.execute((\"import matplotlib.pyplot as plt\\n\"", "shell.execute((\"import matplotlib.pyplot as plt\\n\"", "from spyder.widgets.collectionseditor import CollectionsEditor", "from spyder.plugins.pylint.main_widget import PylintWidgetActions", "shell.execute('def foo(): import foo')", "code = (\"import time\\n\"", "from qtpy.QtCore import Qt", "code_def = \"import qtpy.QtCore\"", "shell.execute(\"import time\\n\"", "code = (\"import time\\n\"", "cmd = 'import sys;print(sys.path)'", "code2 = (\"from tmp import a\\n\"", "code2 = (\"from tmp import a\\n\"", "'import time\\n'", "'import time\\n'", "'from file1 import f\\n'", "text = (\"import multiprocessing\\n\"", "\"import traceback\\n\"", "text = (\"import multiprocessing\\n\"", "\"import traceback\\n\"", "import multiprocessing", "import sys", "import ctypes; ctypes.string_at(0)", "\"import threading\\n\"", "'import threading\\n'", "import pprint", "shell.execute(\"import ctypes; ctypes.string_at(0)\")", "shell.execute('import time')", "shell.execute('import time')", "shell.execute(\"import sys; sys_path = sys.path\")", "shell1.execute(\"import sys; sys_path = sys.path\")", "s.execute(\"import sys; sys_path = sys.path\")" ]
326
351
def test_get_help_combo(main_window, qtbot): """ Test that Help can display docstrings for names typed in its combobox. """ # Wait until the window is fully up shell = main_window.ipyconsole.get_current_shellwidget() qtbot.waitUntil( lambda: shell.spyder_kernel_ready and shell._prompt_html is not None, timeout=SHELL_TIMEOUT) help_plugin = main_window.help webview = help_plugin.get_widget().rich_text.webview._webview if WEBENGINE: webpage = webview.page() else: webpage = webview.page().mainFrame() # --- From the console --- # Write some object in the console with qtbot.waitSignal(shell.executed): shell.execute('import numpy as np') # Get help - numpy object_combo = help_plugin.get_widget().object_combo object_combo.setFocus() qtbot.keyClicks(object_combo, 'numpy', delay=100) # Check that a expected text is part of the page qtbot.waitUntil(lambda: check_text(webpage, "NumPy"), timeout=6000) # Get help - numpy.arange qtbot.keyClicks(object_combo, '.arange', delay=100) # Check that a expected text is part of the page qtbot.waitUntil(lambda: check_text(webpage, "arange"), timeout=6000) # Get help - np # Clear combo object_combo.set_current_text('') qtbot.keyClicks(object_combo, 'np', delay=100) # Check that a expected text is part of the page qtbot.waitUntil(lambda: check_text(webpage, "NumPy"), timeout=6000)
test_mainwindow.py
spyder.spyder.app.tests
false
true
[ "import gc", "import os", "import os.path as osp", "from pathlib import Path", "import random", "import re", "import shutil", "import sys", "import tempfile", "from textwrap import dedent", "import time", "from unittest.mock import Mock", "import uuid", "from flaky import flaky", "import ipykernel", "from IPython.core import release as ipy_release", "from matplotlib.testing.compare import compare_images", "import nbconvert", "import numpy as np", "from numpy.testing import assert_array_equal", "from packaging.version import parse", "import pylint", "import pytest", "from qtpy import PYQT_VERSION, PYQT5", "from qtpy.QtCore import QPoint, Qt, QTimer", "from qtpy.QtGui import QImage, QTextCursor", "from qtpy.QtWidgets import QAction, QApplication, QInputDialog, QWidget", "from qtpy.QtWebEngineWidgets import WEBENGINE", "from spyder import __trouble_url__", "from spyder.api.utils import get_class_values", "from spyder.api.widgets.auxiliary_widgets import SpyderWindowWidget", "from spyder.api.plugins import Plugins", "from spyder.app.tests.conftest import (", "from spyder.config.base import (", "from spyder.config.manager import CONF", "from spyder.dependencies import DEPENDENCIES", "from spyder.plugins.debugger.api import DebuggerWidgetActions", "from spyder.plugins.externalterminal.api import ExtTerminalShConfiguration", "from spyder.plugins.help.widgets import ObjectComboBox", "from spyder.plugins.help.tests.test_plugin import check_text", "from spyder.plugins.ipythonconsole.utils.kernel_handler import KernelHandler", "from spyder.plugins.ipythonconsole.api import (", "from spyder.plugins.mainmenu.api import ApplicationMenus", "from spyder.plugins.layout.layouts import DefaultLayouts", "from spyder.plugins.toolbar.api import ApplicationToolbars", "from spyder.plugins.run.api import (", "from spyder.py3compat import qbytearray_to_str, to_text_string", "from spyder.utils.environ import set_user_env", "from spyder.utils.misc import remove_backslashes, rename_file", "from spyder.utils.clipboard_helper import CLIPBOARD_HELPER", "from spyder.utils.programs import find_program", "from spyder.widgets.dock import DockTitleBar", "\"import sys\\n\"", "\"from spyder.utils.external import lockfile\\n\"", "shell.execute('import numpy as np; A=np.full(16, np.nan)')", "shell.execute('import numpy as np')", "(\"import numpy as np\", \"An array object of arbitrary homogeneous items\")])", "shell.execute('import os; current_dir = os.getcwd()')", "shell.execute('import os; current_dir = os.getcwd()')", "shell.execute(\"import sys; import os; \"", "shell.execute(\"import sys; import os; \"", "qtbot.keyClicks(control, 'import os; os.getcwd()')", "shell.execute((\"import matplotlib.pyplot as plt\\n\"", "shell.execute((\"import matplotlib.pyplot as plt\\n\"", "\"import time\\n\"", "shell.execute((\"import matplotlib.pyplot as plt\\n\"", "shell.execute((\"import matplotlib.pyplot as plt\\n\"", "from spyder.widgets.collectionseditor import CollectionsEditor", "from spyder.plugins.pylint.main_widget import PylintWidgetActions", "shell.execute('def foo(): import foo')", "code = (\"import time\\n\"", "from qtpy.QtCore import Qt", "code_def = \"import qtpy.QtCore\"", "shell.execute(\"import time\\n\"", "code = (\"import time\\n\"", "cmd = 'import sys;print(sys.path)'", "code2 = (\"from tmp import a\\n\"", "code2 = (\"from tmp import a\\n\"", "'import time\\n'", "'import time\\n'", "'from file1 import f\\n'", "text = (\"import multiprocessing\\n\"", "\"import traceback\\n\"", "text = (\"import multiprocessing\\n\"", "\"import traceback\\n\"", "import multiprocessing", "import sys", "import ctypes; ctypes.string_at(0)", "\"import threading\\n\"", "'import threading\\n'", "import pprint", "shell.execute(\"import ctypes; ctypes.string_at(0)\")", "shell.execute('import time')", "shell.execute('import time')", "shell.execute(\"import sys; sys_path = sys.path\")", "shell1.execute(\"import sys; sys_path = sys.path\")", "s.execute(\"import sys; sys_path = sys.path\")" ]
358
402
qtbot.keyClicks(object_combo, 'np', delay=100) # Check that a expected text is part of the page qtbot.waitUntil(lambda: check_text(webpage, "NumPy"), timeout=6000) # Get help - np.arange qtbot.keyClicks(object_combo, '.arange', delay=100) # Check that a expected text is part of the page qtbot.waitUntil(lambda: check_text(webpage, "arange"), timeout=6000)
test_mainwindow.py
spyder.spyder.app.tests
false
false
[ "import gc", "import os", "import os.path as osp", "from pathlib import Path", "import random", "import re", "import shutil", "import sys", "import tempfile", "from textwrap import dedent", "import time", "from unittest.mock import Mock", "import uuid", "from flaky import flaky", "import ipykernel", "from IPython.core import release as ipy_release", "from matplotlib.testing.compare import compare_images", "import nbconvert", "import numpy as np", "from numpy.testing import assert_array_equal", "from packaging.version import parse", "import pylint", "import pytest", "from qtpy import PYQT_VERSION, PYQT5", "from qtpy.QtCore import QPoint, Qt, QTimer", "from qtpy.QtGui import QImage, QTextCursor", "from qtpy.QtWidgets import QAction, QApplication, QInputDialog, QWidget", "from qtpy.QtWebEngineWidgets import WEBENGINE", "from spyder import __trouble_url__", "from spyder.api.utils import get_class_values", "from spyder.api.widgets.auxiliary_widgets import SpyderWindowWidget", "from spyder.api.plugins import Plugins", "from spyder.app.tests.conftest import (", "from spyder.config.base import (", "from spyder.config.manager import CONF", "from spyder.dependencies import DEPENDENCIES", "from spyder.plugins.debugger.api import DebuggerWidgetActions", "from spyder.plugins.externalterminal.api import ExtTerminalShConfiguration", "from spyder.plugins.help.widgets import ObjectComboBox", "from spyder.plugins.help.tests.test_plugin import check_text", "from spyder.plugins.ipythonconsole.utils.kernel_handler import KernelHandler", "from spyder.plugins.ipythonconsole.api import (", "from spyder.plugins.mainmenu.api import ApplicationMenus", "from spyder.plugins.layout.layouts import DefaultLayouts", "from spyder.plugins.toolbar.api import ApplicationToolbars", "from spyder.plugins.run.api import (", "from spyder.py3compat import qbytearray_to_str, to_text_string", "from spyder.utils.environ import set_user_env", "from spyder.utils.misc import remove_backslashes, rename_file", "from spyder.utils.clipboard_helper import CLIPBOARD_HELPER", "from spyder.utils.programs import find_program", "from spyder.widgets.dock import DockTitleBar", "\"import sys\\n\"", "\"from spyder.utils.external import lockfile\\n\"", "shell.execute('import numpy as np; A=np.full(16, np.nan)')", "shell.execute('import numpy as np')", "(\"import numpy as np\", \"An array object of arbitrary homogeneous items\")])", "shell.execute('import os; current_dir = os.getcwd()')", "shell.execute('import os; current_dir = os.getcwd()')", "shell.execute(\"import sys; import os; \"", "shell.execute(\"import sys; import os; \"", "qtbot.keyClicks(control, 'import os; os.getcwd()')", "shell.execute((\"import matplotlib.pyplot as plt\\n\"", "shell.execute((\"import matplotlib.pyplot as plt\\n\"", "\"import time\\n\"", "shell.execute((\"import matplotlib.pyplot as plt\\n\"", "shell.execute((\"import matplotlib.pyplot as plt\\n\"", "from spyder.widgets.collectionseditor import CollectionsEditor", "from spyder.plugins.pylint.main_widget import PylintWidgetActions", "shell.execute('def foo(): import foo')", "code = (\"import time\\n\"", "from qtpy.QtCore import Qt", "code_def = \"import qtpy.QtCore\"", "shell.execute(\"import time\\n\"", "code = (\"import time\\n\"", "cmd = 'import sys;print(sys.path)'", "code2 = (\"from tmp import a\\n\"", "code2 = (\"from tmp import a\\n\"", "'import time\\n'", "'import time\\n'", "'from file1 import f\\n'", "text = (\"import multiprocessing\\n\"", "\"import traceback\\n\"", "text = (\"import multiprocessing\\n\"", "\"import traceback\\n\"", "import multiprocessing", "import sys", "import ctypes; ctypes.string_at(0)", "\"import threading\\n\"", "'import threading\\n'", "import pprint", "shell.execute(\"import ctypes; ctypes.string_at(0)\")", "shell.execute('import time')", "shell.execute('import time')", "shell.execute(\"import sys; sys_path = sys.path\")", "shell1.execute(\"import sys; sys_path = sys.path\")", "s.execute(\"import sys; sys_path = sys.path\")" ]
399
408
def test_get_help_ipython_console_dot_notation(main_window, qtbot, tmpdir): """ Test that Help works when called from the IPython console with dot calls i.e np.sin See spyder-ide/spyder#11821 """ shell = main_window.ipyconsole.get_current_shellwidget() control = shell._control qtbot.waitUntil( lambda: shell.spyder_kernel_ready and shell._prompt_html is not None, timeout=SHELL_TIMEOUT) # Open test file test_file = osp.join(LOCATION, 'script_unicode.py') main_window.editor.load(test_file) code_editor = main_window.editor.get_focus_widget() run_parameters = generate_run_parameters(main_window, test_file) CONF.set('run', 'last_used_parameters', run_parameters) # Run test file qtbot.keyClick(code_editor, Qt.Key_F5) qtbot.wait(500) help_plugin = main_window.help webview = help_plugin.get_widget().rich_text.webview._webview webpage = webview.page() if WEBENGINE else webview.page().mainFrame() # Write function name qtbot.keyClicks(control, u'np.linalg.norm') # Get help control.inspect_current_object() # Check that a expected text is part of the page qtbot.waitUntil( lambda: check_text(webpage, "Matrix or vector norm."), timeout=6000)
test_mainwindow.py
spyder.spyder.app.tests
false
true
[ "import gc", "import os", "import os.path as osp", "from pathlib import Path", "import random", "import re", "import shutil", "import sys", "import tempfile", "from textwrap import dedent", "import time", "from unittest.mock import Mock", "import uuid", "from flaky import flaky", "import ipykernel", "from IPython.core import release as ipy_release", "from matplotlib.testing.compare import compare_images", "import nbconvert", "import numpy as np", "from numpy.testing import assert_array_equal", "from packaging.version import parse", "import pylint", "import pytest", "from qtpy import PYQT_VERSION, PYQT5", "from qtpy.QtCore import QPoint, Qt, QTimer", "from qtpy.QtGui import QImage, QTextCursor", "from qtpy.QtWidgets import QAction, QApplication, QInputDialog, QWidget", "from qtpy.QtWebEngineWidgets import WEBENGINE", "from spyder import __trouble_url__", "from spyder.api.utils import get_class_values", "from spyder.api.widgets.auxiliary_widgets import SpyderWindowWidget", "from spyder.api.plugins import Plugins", "from spyder.app.tests.conftest import (", "from spyder.config.base import (", "from spyder.config.manager import CONF", "from spyder.dependencies import DEPENDENCIES", "from spyder.plugins.debugger.api import DebuggerWidgetActions", "from spyder.plugins.externalterminal.api import ExtTerminalShConfiguration", "from spyder.plugins.help.widgets import ObjectComboBox", "from spyder.plugins.help.tests.test_plugin import check_text", "from spyder.plugins.ipythonconsole.utils.kernel_handler import KernelHandler", "from spyder.plugins.ipythonconsole.api import (", "from spyder.plugins.mainmenu.api import ApplicationMenus", "from spyder.plugins.layout.layouts import DefaultLayouts", "from spyder.plugins.toolbar.api import ApplicationToolbars", "from spyder.plugins.run.api import (", "from spyder.py3compat import qbytearray_to_str, to_text_string", "from spyder.utils.environ import set_user_env", "from spyder.utils.misc import remove_backslashes, rename_file", "from spyder.utils.clipboard_helper import CLIPBOARD_HELPER", "from spyder.utils.programs import find_program", "from spyder.widgets.dock import DockTitleBar", "\"import sys\\n\"", "\"from spyder.utils.external import lockfile\\n\"", "shell.execute('import numpy as np; A=np.full(16, np.nan)')", "shell.execute('import numpy as np')", "(\"import numpy as np\", \"An array object of arbitrary homogeneous items\")])", "shell.execute('import os; current_dir = os.getcwd()')", "shell.execute('import os; current_dir = os.getcwd()')", "shell.execute(\"import sys; import os; \"", "shell.execute(\"import sys; import os; \"", "qtbot.keyClicks(control, 'import os; os.getcwd()')", "shell.execute((\"import matplotlib.pyplot as plt\\n\"", "shell.execute((\"import matplotlib.pyplot as plt\\n\"", "\"import time\\n\"", "shell.execute((\"import matplotlib.pyplot as plt\\n\"", "shell.execute((\"import matplotlib.pyplot as plt\\n\"", "from spyder.widgets.collectionseditor import CollectionsEditor", "from spyder.plugins.pylint.main_widget import PylintWidgetActions", "shell.execute('def foo(): import foo')", "code = (\"import time\\n\"", "from qtpy.QtCore import Qt", "code_def = \"import qtpy.QtCore\"", "shell.execute(\"import time\\n\"", "code = (\"import time\\n\"", "cmd = 'import sys;print(sys.path)'", "code2 = (\"from tmp import a\\n\"", "code2 = (\"from tmp import a\\n\"", "'import time\\n'", "'import time\\n'", "'from file1 import f\\n'", "text = (\"import multiprocessing\\n\"", "\"import traceback\\n\"", "text = (\"import multiprocessing\\n\"", "\"import traceback\\n\"", "import multiprocessing", "import sys", "import ctypes; ctypes.string_at(0)", "\"import threading\\n\"", "'import threading\\n'", "import pprint", "shell.execute(\"import ctypes; ctypes.string_at(0)\")", "shell.execute('import time')", "shell.execute('import time')", "shell.execute(\"import sys; sys_path = sys.path\")", "shell1.execute(\"import sys; sys_path = sys.path\")", "s.execute(\"import sys; sys_path = sys.path\")" ]
412
450
def test_get_help_ipython_console_special_characters( main_window, qtbot, tmpdir): """ Test that Help works when called from the IPython console for unusual characters. See spyder-ide/spyder#7699 """ shell = main_window.ipyconsole.get_current_shellwidget() control = shell._control qtbot.waitUntil( lambda: shell.spyder_kernel_ready and shell._prompt_html is not None, timeout=SHELL_TIMEOUT) # Open test file test_file = osp.join(LOCATION, 'script_unicode.py') main_window.editor.load(test_file) code_editor = main_window.editor.get_focus_widget() run_parameters = generate_run_parameters(main_window, test_file) CONF.set('run', 'last_used_parameters', run_parameters) # Run test file qtbot.keyClick(code_editor, Qt.Key_F5) qtbot.wait(500) help_plugin = main_window.help webview = help_plugin.get_widget().rich_text.webview._webview webpage = webview.page() if WEBENGINE else webview.page().mainFrame() # Write function name and assert in Console def check_control(control, value): return value in control.toPlainText() qtbot.keyClicks(control, u'aa\t') qtbot.waitUntil(lambda: check_control(control, u'aaʹbb'), timeout=SHELL_TIMEOUT) # Get help control.inspect_current_object()
test_mainwindow.py
spyder.spyder.app.tests
false
true
[ "import gc", "import os", "import os.path as osp", "from pathlib import Path", "import random", "import re", "import shutil", "import sys", "import tempfile", "from textwrap import dedent", "import time", "from unittest.mock import Mock", "import uuid", "from flaky import flaky", "import ipykernel", "from IPython.core import release as ipy_release", "from matplotlib.testing.compare import compare_images", "import nbconvert", "import numpy as np", "from numpy.testing import assert_array_equal", "from packaging.version import parse", "import pylint", "import pytest", "from qtpy import PYQT_VERSION, PYQT5", "from qtpy.QtCore import QPoint, Qt, QTimer", "from qtpy.QtGui import QImage, QTextCursor", "from qtpy.QtWidgets import QAction, QApplication, QInputDialog, QWidget", "from qtpy.QtWebEngineWidgets import WEBENGINE", "from spyder import __trouble_url__", "from spyder.api.utils import get_class_values", "from spyder.api.widgets.auxiliary_widgets import SpyderWindowWidget", "from spyder.api.plugins import Plugins", "from spyder.app.tests.conftest import (", "from spyder.config.base import (", "from spyder.config.manager import CONF", "from spyder.dependencies import DEPENDENCIES", "from spyder.plugins.debugger.api import DebuggerWidgetActions", "from spyder.plugins.externalterminal.api import ExtTerminalShConfiguration", "from spyder.plugins.help.widgets import ObjectComboBox", "from spyder.plugins.help.tests.test_plugin import check_text", "from spyder.plugins.ipythonconsole.utils.kernel_handler import KernelHandler", "from spyder.plugins.ipythonconsole.api import (", "from spyder.plugins.mainmenu.api import ApplicationMenus", "from spyder.plugins.layout.layouts import DefaultLayouts", "from spyder.plugins.toolbar.api import ApplicationToolbars", "from spyder.plugins.run.api import (", "from spyder.py3compat import qbytearray_to_str, to_text_string", "from spyder.utils.environ import set_user_env", "from spyder.utils.misc import remove_backslashes, rename_file", "from spyder.utils.clipboard_helper import CLIPBOARD_HELPER", "from spyder.utils.programs import find_program", "from spyder.widgets.dock import DockTitleBar", "\"import sys\\n\"", "\"from spyder.utils.external import lockfile\\n\"", "shell.execute('import numpy as np; A=np.full(16, np.nan)')", "shell.execute('import numpy as np')", "(\"import numpy as np\", \"An array object of arbitrary homogeneous items\")])", "shell.execute('import os; current_dir = os.getcwd()')", "shell.execute('import os; current_dir = os.getcwd()')", "shell.execute(\"import sys; import os; \"", "shell.execute(\"import sys; import os; \"", "qtbot.keyClicks(control, 'import os; os.getcwd()')", "shell.execute((\"import matplotlib.pyplot as plt\\n\"", "shell.execute((\"import matplotlib.pyplot as plt\\n\"", "\"import time\\n\"", "shell.execute((\"import matplotlib.pyplot as plt\\n\"", "shell.execute((\"import matplotlib.pyplot as plt\\n\"", "from spyder.widgets.collectionseditor import CollectionsEditor", "from spyder.plugins.pylint.main_widget import PylintWidgetActions", "shell.execute('def foo(): import foo')", "code = (\"import time\\n\"", "from qtpy.QtCore import Qt", "code_def = \"import qtpy.QtCore\"", "shell.execute(\"import time\\n\"", "code = (\"import time\\n\"", "cmd = 'import sys;print(sys.path)'", "code2 = (\"from tmp import a\\n\"", "code2 = (\"from tmp import a\\n\"", "'import time\\n'", "'import time\\n'", "'from file1 import f\\n'", "text = (\"import multiprocessing\\n\"", "\"import traceback\\n\"", "text = (\"import multiprocessing\\n\"", "\"import traceback\\n\"", "import multiprocessing", "import sys", "import ctypes; ctypes.string_at(0)", "\"import threading\\n\"", "'import threading\\n'", "import pprint", "shell.execute(\"import ctypes; ctypes.string_at(0)\")", "shell.execute('import time')", "shell.execute('import time')", "shell.execute(\"import sys; sys_path = sys.path\")", "shell1.execute(\"import sys; sys_path = sys.path\")", "s.execute(\"import sys; sys_path = sys.path\")" ]
456
495
qtbot.keyClicks(control, u'aa\t') qtbot.waitUntil(lambda: check_control(control, u'aaʹbb'), timeout=SHELL_TIMEOUT) # Get help control.inspect_current_object() # Check that a expected text is part of the page qtbot.waitUntil(lambda: check_text(webpage, "This function docstring."), timeout=6000)
test_mainwindow.py
spyder.spyder.app.tests
false
false
[ "import gc", "import os", "import os.path as osp", "from pathlib import Path", "import random", "import re", "import shutil", "import sys", "import tempfile", "from textwrap import dedent", "import time", "from unittest.mock import Mock", "import uuid", "from flaky import flaky", "import ipykernel", "from IPython.core import release as ipy_release", "from matplotlib.testing.compare import compare_images", "import nbconvert", "import numpy as np", "from numpy.testing import assert_array_equal", "from packaging.version import parse", "import pylint", "import pytest", "from qtpy import PYQT_VERSION, PYQT5", "from qtpy.QtCore import QPoint, Qt, QTimer", "from qtpy.QtGui import QImage, QTextCursor", "from qtpy.QtWidgets import QAction, QApplication, QInputDialog, QWidget", "from qtpy.QtWebEngineWidgets import WEBENGINE", "from spyder import __trouble_url__", "from spyder.api.utils import get_class_values", "from spyder.api.widgets.auxiliary_widgets import SpyderWindowWidget", "from spyder.api.plugins import Plugins", "from spyder.app.tests.conftest import (", "from spyder.config.base import (", "from spyder.config.manager import CONF", "from spyder.dependencies import DEPENDENCIES", "from spyder.plugins.debugger.api import DebuggerWidgetActions", "from spyder.plugins.externalterminal.api import ExtTerminalShConfiguration", "from spyder.plugins.help.widgets import ObjectComboBox", "from spyder.plugins.help.tests.test_plugin import check_text", "from spyder.plugins.ipythonconsole.utils.kernel_handler import KernelHandler", "from spyder.plugins.ipythonconsole.api import (", "from spyder.plugins.mainmenu.api import ApplicationMenus", "from spyder.plugins.layout.layouts import DefaultLayouts", "from spyder.plugins.toolbar.api import ApplicationToolbars", "from spyder.plugins.run.api import (", "from spyder.py3compat import qbytearray_to_str, to_text_string", "from spyder.utils.environ import set_user_env", "from spyder.utils.misc import remove_backslashes, rename_file", "from spyder.utils.clipboard_helper import CLIPBOARD_HELPER", "from spyder.utils.programs import find_program", "from spyder.widgets.dock import DockTitleBar", "\"import sys\\n\"", "\"from spyder.utils.external import lockfile\\n\"", "shell.execute('import numpy as np; A=np.full(16, np.nan)')", "shell.execute('import numpy as np')", "(\"import numpy as np\", \"An array object of arbitrary homogeneous items\")])", "shell.execute('import os; current_dir = os.getcwd()')", "shell.execute('import os; current_dir = os.getcwd()')", "shell.execute(\"import sys; import os; \"", "shell.execute(\"import sys; import os; \"", "qtbot.keyClicks(control, 'import os; os.getcwd()')", "shell.execute((\"import matplotlib.pyplot as plt\\n\"", "shell.execute((\"import matplotlib.pyplot as plt\\n\"", "\"import time\\n\"", "shell.execute((\"import matplotlib.pyplot as plt\\n\"", "shell.execute((\"import matplotlib.pyplot as plt\\n\"", "from spyder.widgets.collectionseditor import CollectionsEditor", "from spyder.plugins.pylint.main_widget import PylintWidgetActions", "shell.execute('def foo(): import foo')", "code = (\"import time\\n\"", "from qtpy.QtCore import Qt", "code_def = \"import qtpy.QtCore\"", "shell.execute(\"import time\\n\"", "code = (\"import time\\n\"", "cmd = 'import sys;print(sys.path)'", "code2 = (\"from tmp import a\\n\"", "code2 = (\"from tmp import a\\n\"", "'import time\\n'", "'import time\\n'", "'from file1 import f\\n'", "text = (\"import multiprocessing\\n\"", "\"import traceback\\n\"", "text = (\"import multiprocessing\\n\"", "\"import traceback\\n\"", "import multiprocessing", "import sys", "import ctypes; ctypes.string_at(0)", "\"import threading\\n\"", "'import threading\\n'", "import pprint", "shell.execute(\"import ctypes; ctypes.string_at(0)\")", "shell.execute('import time')", "shell.execute('import time')", "shell.execute(\"import sys; sys_path = sys.path\")", "shell1.execute(\"import sys; sys_path = sys.path\")", "s.execute(\"import sys; sys_path = sys.path\")" ]
490
499
def test_get_help_ipython_console(main_window, qtbot): """Test that Help works when called from the IPython console.""" shell = main_window.ipyconsole.get_current_shellwidget() control = shell._control qtbot.waitUntil( lambda: shell.spyder_kernel_ready and shell._prompt_html is not None, timeout=SHELL_TIMEOUT) help_plugin = main_window.help webview = help_plugin.get_widget().rich_text.webview._webview webpage = webview.page() if WEBENGINE else webview.page().mainFrame() # Write some object in the console qtbot.keyClicks(control, 'get_ipython') # Get help control.inspect_current_object() # Check that a expected text is part of the page qtbot.waitUntil(lambda: check_text(webpage, "SpyderShell"), timeout=6000)
test_mainwindow.py
spyder.spyder.app.tests
false
true
[ "import gc", "import os", "import os.path as osp", "from pathlib import Path", "import random", "import re", "import shutil", "import sys", "import tempfile", "from textwrap import dedent", "import time", "from unittest.mock import Mock", "import uuid", "from flaky import flaky", "import ipykernel", "from IPython.core import release as ipy_release", "from matplotlib.testing.compare import compare_images", "import nbconvert", "import numpy as np", "from numpy.testing import assert_array_equal", "from packaging.version import parse", "import pylint", "import pytest", "from qtpy import PYQT_VERSION, PYQT5", "from qtpy.QtCore import QPoint, Qt, QTimer", "from qtpy.QtGui import QImage, QTextCursor", "from qtpy.QtWidgets import QAction, QApplication, QInputDialog, QWidget", "from qtpy.QtWebEngineWidgets import WEBENGINE", "from spyder import __trouble_url__", "from spyder.api.utils import get_class_values", "from spyder.api.widgets.auxiliary_widgets import SpyderWindowWidget", "from spyder.api.plugins import Plugins", "from spyder.app.tests.conftest import (", "from spyder.config.base import (", "from spyder.config.manager import CONF", "from spyder.dependencies import DEPENDENCIES", "from spyder.plugins.debugger.api import DebuggerWidgetActions", "from spyder.plugins.externalterminal.api import ExtTerminalShConfiguration", "from spyder.plugins.help.widgets import ObjectComboBox", "from spyder.plugins.help.tests.test_plugin import check_text", "from spyder.plugins.ipythonconsole.utils.kernel_handler import KernelHandler", "from spyder.plugins.ipythonconsole.api import (", "from spyder.plugins.mainmenu.api import ApplicationMenus", "from spyder.plugins.layout.layouts import DefaultLayouts", "from spyder.plugins.toolbar.api import ApplicationToolbars", "from spyder.plugins.run.api import (", "from spyder.py3compat import qbytearray_to_str, to_text_string", "from spyder.utils.environ import set_user_env", "from spyder.utils.misc import remove_backslashes, rename_file", "from spyder.utils.clipboard_helper import CLIPBOARD_HELPER", "from spyder.utils.programs import find_program", "from spyder.widgets.dock import DockTitleBar", "\"import sys\\n\"", "\"from spyder.utils.external import lockfile\\n\"", "shell.execute('import numpy as np; A=np.full(16, np.nan)')", "shell.execute('import numpy as np')", "(\"import numpy as np\", \"An array object of arbitrary homogeneous items\")])", "shell.execute('import os; current_dir = os.getcwd()')", "shell.execute('import os; current_dir = os.getcwd()')", "shell.execute(\"import sys; import os; \"", "shell.execute(\"import sys; import os; \"", "qtbot.keyClicks(control, 'import os; os.getcwd()')", "shell.execute((\"import matplotlib.pyplot as plt\\n\"", "shell.execute((\"import matplotlib.pyplot as plt\\n\"", "\"import time\\n\"", "shell.execute((\"import matplotlib.pyplot as plt\\n\"", "shell.execute((\"import matplotlib.pyplot as plt\\n\"", "from spyder.widgets.collectionseditor import CollectionsEditor", "from spyder.plugins.pylint.main_widget import PylintWidgetActions", "shell.execute('def foo(): import foo')", "code = (\"import time\\n\"", "from qtpy.QtCore import Qt", "code_def = \"import qtpy.QtCore\"", "shell.execute(\"import time\\n\"", "code = (\"import time\\n\"", "cmd = 'import sys;print(sys.path)'", "code2 = (\"from tmp import a\\n\"", "code2 = (\"from tmp import a\\n\"", "'import time\\n'", "'import time\\n'", "'from file1 import f\\n'", "text = (\"import multiprocessing\\n\"", "\"import traceback\\n\"", "text = (\"import multiprocessing\\n\"", "\"import traceback\\n\"", "import multiprocessing", "import sys", "import ctypes; ctypes.string_at(0)", "\"import threading\\n\"", "'import threading\\n'", "import pprint", "shell.execute(\"import ctypes; ctypes.string_at(0)\")", "shell.execute('import time')", "shell.execute('import time')", "shell.execute(\"import sys; sys_path = sys.path\")", "shell1.execute(\"import sys; sys_path = sys.path\")", "s.execute(\"import sys; sys_path = sys.path\")" ]
505
524
def test_get_help_editor(main_window, qtbot, object_info): """Test that Help works when called from the Editor.""" # Wait until the window is fully up # Wait until the window is fully up shell = main_window.ipyconsole.get_current_shellwidget() qtbot.waitUntil( lambda: shell.spyder_kernel_ready and shell._prompt_html is not None, timeout=SHELL_TIMEOUT) help_plugin = main_window.help webview = help_plugin.get_widget().rich_text.webview._webview webpage = webview.page() if WEBENGINE else webview.page().mainFrame() main_window.editor.new(fname="test.py", text="") code_editor = main_window.editor.get_focus_widget() editorstack = main_window.editor.get_current_editorstack() qtbot.waitUntil(lambda: code_editor.completions_available, timeout=COMPLETION_TIMEOUT) # Write some object in the editor object_name, expected_text = object_info code_editor.set_text(object_name) code_editor.move_cursor(len(object_name)) with qtbot.waitSignal(code_editor.completions_response_signal, timeout=COMPLETION_TIMEOUT): code_editor.document_did_change() # Get help with qtbot.waitSignal(code_editor.sig_display_object_info, timeout=30000): editorstack.inspect_current_object() # Check that a expected text is part of the page qtbot.waitUntil(lambda: check_text(webpage, expected_text), timeout=30000)
test_mainwindow.py
spyder.spyder.app.tests
false
true
[ "import gc", "import os", "import os.path as osp", "from pathlib import Path", "import random", "import re", "import shutil", "import sys", "import tempfile", "from textwrap import dedent", "import time", "from unittest.mock import Mock", "import uuid", "from flaky import flaky", "import ipykernel", "from IPython.core import release as ipy_release", "from matplotlib.testing.compare import compare_images", "import nbconvert", "import numpy as np", "from numpy.testing import assert_array_equal", "from packaging.version import parse", "import pylint", "import pytest", "from qtpy import PYQT_VERSION, PYQT5", "from qtpy.QtCore import QPoint, Qt, QTimer", "from qtpy.QtGui import QImage, QTextCursor", "from qtpy.QtWidgets import QAction, QApplication, QInputDialog, QWidget", "from qtpy.QtWebEngineWidgets import WEBENGINE", "from spyder import __trouble_url__", "from spyder.api.utils import get_class_values", "from spyder.api.widgets.auxiliary_widgets import SpyderWindowWidget", "from spyder.api.plugins import Plugins", "from spyder.app.tests.conftest import (", "from spyder.config.base import (", "from spyder.config.manager import CONF", "from spyder.dependencies import DEPENDENCIES", "from spyder.plugins.debugger.api import DebuggerWidgetActions", "from spyder.plugins.externalterminal.api import ExtTerminalShConfiguration", "from spyder.plugins.help.widgets import ObjectComboBox", "from spyder.plugins.help.tests.test_plugin import check_text", "from spyder.plugins.ipythonconsole.utils.kernel_handler import KernelHandler", "from spyder.plugins.ipythonconsole.api import (", "from spyder.plugins.mainmenu.api import ApplicationMenus", "from spyder.plugins.layout.layouts import DefaultLayouts", "from spyder.plugins.toolbar.api import ApplicationToolbars", "from spyder.plugins.run.api import (", "from spyder.py3compat import qbytearray_to_str, to_text_string", "from spyder.utils.environ import set_user_env", "from spyder.utils.misc import remove_backslashes, rename_file", "from spyder.utils.clipboard_helper import CLIPBOARD_HELPER", "from spyder.utils.programs import find_program", "from spyder.widgets.dock import DockTitleBar", "\"import sys\\n\"", "\"from spyder.utils.external import lockfile\\n\"", "shell.execute('import numpy as np; A=np.full(16, np.nan)')", "shell.execute('import numpy as np')", "(\"import numpy as np\", \"An array object of arbitrary homogeneous items\")])", "shell.execute('import os; current_dir = os.getcwd()')", "shell.execute('import os; current_dir = os.getcwd()')", "shell.execute(\"import sys; import os; \"", "shell.execute(\"import sys; import os; \"", "qtbot.keyClicks(control, 'import os; os.getcwd()')", "shell.execute((\"import matplotlib.pyplot as plt\\n\"", "shell.execute((\"import matplotlib.pyplot as plt\\n\"", "\"import time\\n\"", "shell.execute((\"import matplotlib.pyplot as plt\\n\"", "shell.execute((\"import matplotlib.pyplot as plt\\n\"", "from spyder.widgets.collectionseditor import CollectionsEditor", "from spyder.plugins.pylint.main_widget import PylintWidgetActions", "shell.execute('def foo(): import foo')", "code = (\"import time\\n\"", "from qtpy.QtCore import Qt", "code_def = \"import qtpy.QtCore\"", "shell.execute(\"import time\\n\"", "code = (\"import time\\n\"", "cmd = 'import sys;print(sys.path)'", "code2 = (\"from tmp import a\\n\"", "code2 = (\"from tmp import a\\n\"", "'import time\\n'", "'import time\\n'", "'from file1 import f\\n'", "text = (\"import multiprocessing\\n\"", "\"import traceback\\n\"", "text = (\"import multiprocessing\\n\"", "\"import traceback\\n\"", "import multiprocessing", "import sys", "import ctypes; ctypes.string_at(0)", "\"import threading\\n\"", "'import threading\\n'", "import pprint", "shell.execute(\"import ctypes; ctypes.string_at(0)\")", "shell.execute('import time')", "shell.execute('import time')", "shell.execute(\"import sys; sys_path = sys.path\")", "shell1.execute(\"import sys; sys_path = sys.path\")", "s.execute(\"import sys; sys_path = sys.path\")" ]
536
568
# Check that a expected text is part of the page qtbot.waitUntil(lambda: check_text(webpage, expected_text), timeout=30000) assert check_text(webpage, expected_text)
test_mainwindow.py
spyder.spyder.app.tests
false
false
[ "import gc", "import os", "import os.path as osp", "from pathlib import Path", "import random", "import re", "import shutil", "import sys", "import tempfile", "from textwrap import dedent", "import time", "from unittest.mock import Mock", "import uuid", "from flaky import flaky", "import ipykernel", "from IPython.core import release as ipy_release", "from matplotlib.testing.compare import compare_images", "import nbconvert", "import numpy as np", "from numpy.testing import assert_array_equal", "from packaging.version import parse", "import pylint", "import pytest", "from qtpy import PYQT_VERSION, PYQT5", "from qtpy.QtCore import QPoint, Qt, QTimer", "from qtpy.QtGui import QImage, QTextCursor", "from qtpy.QtWidgets import QAction, QApplication, QInputDialog, QWidget", "from qtpy.QtWebEngineWidgets import WEBENGINE", "from spyder import __trouble_url__", "from spyder.api.utils import get_class_values", "from spyder.api.widgets.auxiliary_widgets import SpyderWindowWidget", "from spyder.api.plugins import Plugins", "from spyder.app.tests.conftest import (", "from spyder.config.base import (", "from spyder.config.manager import CONF", "from spyder.dependencies import DEPENDENCIES", "from spyder.plugins.debugger.api import DebuggerWidgetActions", "from spyder.plugins.externalterminal.api import ExtTerminalShConfiguration", "from spyder.plugins.help.widgets import ObjectComboBox", "from spyder.plugins.help.tests.test_plugin import check_text", "from spyder.plugins.ipythonconsole.utils.kernel_handler import KernelHandler", "from spyder.plugins.ipythonconsole.api import (", "from spyder.plugins.mainmenu.api import ApplicationMenus", "from spyder.plugins.layout.layouts import DefaultLayouts", "from spyder.plugins.toolbar.api import ApplicationToolbars", "from spyder.plugins.run.api import (", "from spyder.py3compat import qbytearray_to_str, to_text_string", "from spyder.utils.environ import set_user_env", "from spyder.utils.misc import remove_backslashes, rename_file", "from spyder.utils.clipboard_helper import CLIPBOARD_HELPER", "from spyder.utils.programs import find_program", "from spyder.widgets.dock import DockTitleBar", "\"import sys\\n\"", "\"from spyder.utils.external import lockfile\\n\"", "shell.execute('import numpy as np; A=np.full(16, np.nan)')", "shell.execute('import numpy as np')", "(\"import numpy as np\", \"An array object of arbitrary homogeneous items\")])", "shell.execute('import os; current_dir = os.getcwd()')", "shell.execute('import os; current_dir = os.getcwd()')", "shell.execute(\"import sys; import os; \"", "shell.execute(\"import sys; import os; \"", "qtbot.keyClicks(control, 'import os; os.getcwd()')", "shell.execute((\"import matplotlib.pyplot as plt\\n\"", "shell.execute((\"import matplotlib.pyplot as plt\\n\"", "\"import time\\n\"", "shell.execute((\"import matplotlib.pyplot as plt\\n\"", "shell.execute((\"import matplotlib.pyplot as plt\\n\"", "from spyder.widgets.collectionseditor import CollectionsEditor", "from spyder.plugins.pylint.main_widget import PylintWidgetActions", "shell.execute('def foo(): import foo')", "code = (\"import time\\n\"", "from qtpy.QtCore import Qt", "code_def = \"import qtpy.QtCore\"", "shell.execute(\"import time\\n\"", "code = (\"import time\\n\"", "cmd = 'import sys;print(sys.path)'", "code2 = (\"from tmp import a\\n\"", "code2 = (\"from tmp import a\\n\"", "'import time\\n'", "'import time\\n'", "'from file1 import f\\n'", "text = (\"import multiprocessing\\n\"", "\"import traceback\\n\"", "text = (\"import multiprocessing\\n\"", "\"import traceback\\n\"", "import multiprocessing", "import sys", "import ctypes; ctypes.string_at(0)", "\"import threading\\n\"", "'import threading\\n'", "import pprint", "shell.execute(\"import ctypes; ctypes.string_at(0)\")", "shell.execute('import time')", "shell.execute('import time')", "shell.execute(\"import sys; sys_path = sys.path\")", "shell1.execute(\"import sys; sys_path = sys.path\")", "s.execute(\"import sys; sys_path = sys.path\")" ]
567
570
def test_window_title(main_window, tmpdir, qtbot): """Test window title with non-ascii characters.""" # Wait until the window is fully up shell = main_window.ipyconsole.get_current_shellwidget() qtbot.waitUntil( lambda: shell.spyder_kernel_ready and shell._prompt_html is not None, timeout=SHELL_TIMEOUT) projects = main_window.projects # Create a project in non-ascii path path = to_text_string(tmpdir.mkdir(u'測試')) projects.open_project(path=path) # Set non-ascii window title main_window._cli_options.window_title = u'اختبار' # Assert window title is computed without errors # and has the expected strings main_window.set_window_title() title = main_window.base_title assert u'Spyder' in title assert u'Python' in title assert u'اختبار' in title assert u'測試' in title projects.close_project()
test_mainwindow.py
spyder.spyder.app.tests
false
true
[ "import gc", "import os", "import os.path as osp", "from pathlib import Path", "import random", "import re", "import shutil", "import sys", "import tempfile", "from textwrap import dedent", "import time", "from unittest.mock import Mock", "import uuid", "from flaky import flaky", "import ipykernel", "from IPython.core import release as ipy_release", "from matplotlib.testing.compare import compare_images", "import nbconvert", "import numpy as np", "from numpy.testing import assert_array_equal", "from packaging.version import parse", "import pylint", "import pytest", "from qtpy import PYQT_VERSION, PYQT5", "from qtpy.QtCore import QPoint, Qt, QTimer", "from qtpy.QtGui import QImage, QTextCursor", "from qtpy.QtWidgets import QAction, QApplication, QInputDialog, QWidget", "from qtpy.QtWebEngineWidgets import WEBENGINE", "from spyder import __trouble_url__", "from spyder.api.utils import get_class_values", "from spyder.api.widgets.auxiliary_widgets import SpyderWindowWidget", "from spyder.api.plugins import Plugins", "from spyder.app.tests.conftest import (", "from spyder.config.base import (", "from spyder.config.manager import CONF", "from spyder.dependencies import DEPENDENCIES", "from spyder.plugins.debugger.api import DebuggerWidgetActions", "from spyder.plugins.externalterminal.api import ExtTerminalShConfiguration", "from spyder.plugins.help.widgets import ObjectComboBox", "from spyder.plugins.help.tests.test_plugin import check_text", "from spyder.plugins.ipythonconsole.utils.kernel_handler import KernelHandler", "from spyder.plugins.ipythonconsole.api import (", "from spyder.plugins.mainmenu.api import ApplicationMenus", "from spyder.plugins.layout.layouts import DefaultLayouts", "from spyder.plugins.toolbar.api import ApplicationToolbars", "from spyder.plugins.run.api import (", "from spyder.py3compat import qbytearray_to_str, to_text_string", "from spyder.utils.environ import set_user_env", "from spyder.utils.misc import remove_backslashes, rename_file", "from spyder.utils.clipboard_helper import CLIPBOARD_HELPER", "from spyder.utils.programs import find_program", "from spyder.widgets.dock import DockTitleBar", "\"import sys\\n\"", "\"from spyder.utils.external import lockfile\\n\"", "shell.execute('import numpy as np; A=np.full(16, np.nan)')", "shell.execute('import numpy as np')", "(\"import numpy as np\", \"An array object of arbitrary homogeneous items\")])", "shell.execute('import os; current_dir = os.getcwd()')", "shell.execute('import os; current_dir = os.getcwd()')", "shell.execute(\"import sys; import os; \"", "shell.execute(\"import sys; import os; \"", "qtbot.keyClicks(control, 'import os; os.getcwd()')", "shell.execute((\"import matplotlib.pyplot as plt\\n\"", "shell.execute((\"import matplotlib.pyplot as plt\\n\"", "\"import time\\n\"", "shell.execute((\"import matplotlib.pyplot as plt\\n\"", "shell.execute((\"import matplotlib.pyplot as plt\\n\"", "from spyder.widgets.collectionseditor import CollectionsEditor", "from spyder.plugins.pylint.main_widget import PylintWidgetActions", "shell.execute('def foo(): import foo')", "code = (\"import time\\n\"", "from qtpy.QtCore import Qt", "code_def = \"import qtpy.QtCore\"", "shell.execute(\"import time\\n\"", "code = (\"import time\\n\"", "cmd = 'import sys;print(sys.path)'", "code2 = (\"from tmp import a\\n\"", "code2 = (\"from tmp import a\\n\"", "'import time\\n'", "'import time\\n'", "'from file1 import f\\n'", "text = (\"import multiprocessing\\n\"", "\"import traceback\\n\"", "text = (\"import multiprocessing\\n\"", "\"import traceback\\n\"", "import multiprocessing", "import sys", "import ctypes; ctypes.string_at(0)", "\"import threading\\n\"", "'import threading\\n'", "import pprint", "shell.execute(\"import ctypes; ctypes.string_at(0)\")", "shell.execute('import time')", "shell.execute('import time')", "shell.execute(\"import sys; sys_path = sys.path\")", "shell1.execute(\"import sys; sys_path = sys.path\")", "s.execute(\"import sys; sys_path = sys.path\")" ]
573
599
def test_move_to_first_breakpoint(main_window, qtbot, debugcell): """Test that we move to the first breakpoint if there's one present.""" # Wait until the window is fully up shell = main_window.ipyconsole.get_current_shellwidget() qtbot.waitUntil( lambda: shell.spyder_kernel_ready and shell._prompt_html is not None, timeout=SHELL_TIMEOUT) # Main variables control = shell._control debug_button = main_window.debug_button # Clear all breakpoints main_window.debugger.clear_all_breakpoints() # Load test file test_file = osp.join(LOCATION, 'script.py') main_window.editor.load(test_file) code_editor = main_window.editor.get_focus_widget() # Set breakpoint code_editor.breakpoints_manager.toogle_breakpoint(line_number=10) qtbot.wait(500) cursor = code_editor.textCursor() cursor.setPosition(0) code_editor.setTextCursor(cursor) if debugcell: # Advance 2 cells for _ in range(2): with qtbot.waitSignal(shell.executed): qtbot.mouseClick(main_window.run_cell_and_advance_button, Qt.LeftButton) # Debug the cell debug_cell_action = main_window.run.get_action( "run cell in debugger") with qtbot.waitSignal(shell.executed): debug_cell_action.trigger()
test_mainwindow.py
spyder.spyder.app.tests
false
true
[ "import gc", "import os", "import os.path as osp", "from pathlib import Path", "import random", "import re", "import shutil", "import sys", "import tempfile", "from textwrap import dedent", "import time", "from unittest.mock import Mock", "import uuid", "from flaky import flaky", "import ipykernel", "from IPython.core import release as ipy_release", "from matplotlib.testing.compare import compare_images", "import nbconvert", "import numpy as np", "from numpy.testing import assert_array_equal", "from packaging.version import parse", "import pylint", "import pytest", "from qtpy import PYQT_VERSION, PYQT5", "from qtpy.QtCore import QPoint, Qt, QTimer", "from qtpy.QtGui import QImage, QTextCursor", "from qtpy.QtWidgets import QAction, QApplication, QInputDialog, QWidget", "from qtpy.QtWebEngineWidgets import WEBENGINE", "from spyder import __trouble_url__", "from spyder.api.utils import get_class_values", "from spyder.api.widgets.auxiliary_widgets import SpyderWindowWidget", "from spyder.api.plugins import Plugins", "from spyder.app.tests.conftest import (", "from spyder.config.base import (", "from spyder.config.manager import CONF", "from spyder.dependencies import DEPENDENCIES", "from spyder.plugins.debugger.api import DebuggerWidgetActions", "from spyder.plugins.externalterminal.api import ExtTerminalShConfiguration", "from spyder.plugins.help.widgets import ObjectComboBox", "from spyder.plugins.help.tests.test_plugin import check_text", "from spyder.plugins.ipythonconsole.utils.kernel_handler import KernelHandler", "from spyder.plugins.ipythonconsole.api import (", "from spyder.plugins.mainmenu.api import ApplicationMenus", "from spyder.plugins.layout.layouts import DefaultLayouts", "from spyder.plugins.toolbar.api import ApplicationToolbars", "from spyder.plugins.run.api import (", "from spyder.py3compat import qbytearray_to_str, to_text_string", "from spyder.utils.environ import set_user_env", "from spyder.utils.misc import remove_backslashes, rename_file", "from spyder.utils.clipboard_helper import CLIPBOARD_HELPER", "from spyder.utils.programs import find_program", "from spyder.widgets.dock import DockTitleBar", "\"import sys\\n\"", "\"from spyder.utils.external import lockfile\\n\"", "shell.execute('import numpy as np; A=np.full(16, np.nan)')", "shell.execute('import numpy as np')", "(\"import numpy as np\", \"An array object of arbitrary homogeneous items\")])", "shell.execute('import os; current_dir = os.getcwd()')", "shell.execute('import os; current_dir = os.getcwd()')", "shell.execute(\"import sys; import os; \"", "shell.execute(\"import sys; import os; \"", "qtbot.keyClicks(control, 'import os; os.getcwd()')", "shell.execute((\"import matplotlib.pyplot as plt\\n\"", "shell.execute((\"import matplotlib.pyplot as plt\\n\"", "\"import time\\n\"", "shell.execute((\"import matplotlib.pyplot as plt\\n\"", "shell.execute((\"import matplotlib.pyplot as plt\\n\"", "from spyder.widgets.collectionseditor import CollectionsEditor", "from spyder.plugins.pylint.main_widget import PylintWidgetActions", "shell.execute('def foo(): import foo')", "code = (\"import time\\n\"", "from qtpy.QtCore import Qt", "code_def = \"import qtpy.QtCore\"", "shell.execute(\"import time\\n\"", "code = (\"import time\\n\"", "cmd = 'import sys;print(sys.path)'", "code2 = (\"from tmp import a\\n\"", "code2 = (\"from tmp import a\\n\"", "'import time\\n'", "'import time\\n'", "'from file1 import f\\n'", "text = (\"import multiprocessing\\n\"", "\"import traceback\\n\"", "text = (\"import multiprocessing\\n\"", "\"import traceback\\n\"", "import multiprocessing", "import sys", "import ctypes; ctypes.string_at(0)", "\"import threading\\n\"", "'import threading\\n'", "import pprint", "shell.execute(\"import ctypes; ctypes.string_at(0)\")", "shell.execute('import time')", "shell.execute('import time')", "shell.execute(\"import sys; sys_path = sys.path\")", "shell1.execute(\"import sys; sys_path = sys.path\")", "s.execute(\"import sys; sys_path = sys.path\")" ]
606
644
# Make sure everything is ready assert shell.kernel_handler.kernel_comm.is_open() assert shell.is_waiting_pdb_input() with qtbot.waitSignal(shell.executed): shell.pdb_execute('!b') assert 'script.py:10' in shell._control.toPlainText() # We need to press continue as we don't test yet if a breakpoint # is in the cell with qtbot.waitSignal(shell.executed): shell.pdb_execute('!c') else: # Click the debug button with qtbot.waitSignal(shell.executed): qtbot.mouseClick(debug_button, Qt.LeftButton) # Verify that we are at first breakpoint shell.clear_console() qtbot.wait(500) with qtbot.waitSignal(shell.executed): shell.pdb_execute("!list") assert "1--> 10 arr = np.array(li)" in control.toPlainText() # Exit debugging with qtbot.waitSignal(shell.executed): shell.pdb_execute("!exit") # Set breakpoint on first line with code code_editor.breakpoints_manager.toogle_breakpoint(line_number=2) # Click the debug button with qtbot.waitSignal(shell.executed): qtbot.mouseClick(debug_button, Qt.LeftButton) # Check we went to the first breakpoint assert "2---> 2 a = 10" in control.toPlainText() # Verify that we are still debugging assert shell.is_waiting_pdb_input()
test_mainwindow.py
spyder.spyder.app.tests
false
false
[ "import gc", "import os", "import os.path as osp", "from pathlib import Path", "import random", "import re", "import shutil", "import sys", "import tempfile", "from textwrap import dedent", "import time", "from unittest.mock import Mock", "import uuid", "from flaky import flaky", "import ipykernel", "from IPython.core import release as ipy_release", "from matplotlib.testing.compare import compare_images", "import nbconvert", "import numpy as np", "from numpy.testing import assert_array_equal", "from packaging.version import parse", "import pylint", "import pytest", "from qtpy import PYQT_VERSION, PYQT5", "from qtpy.QtCore import QPoint, Qt, QTimer", "from qtpy.QtGui import QImage, QTextCursor", "from qtpy.QtWidgets import QAction, QApplication, QInputDialog, QWidget", "from qtpy.QtWebEngineWidgets import WEBENGINE", "from spyder import __trouble_url__", "from spyder.api.utils import get_class_values", "from spyder.api.widgets.auxiliary_widgets import SpyderWindowWidget", "from spyder.api.plugins import Plugins", "from spyder.app.tests.conftest import (", "from spyder.config.base import (", "from spyder.config.manager import CONF", "from spyder.dependencies import DEPENDENCIES", "from spyder.plugins.debugger.api import DebuggerWidgetActions", "from spyder.plugins.externalterminal.api import ExtTerminalShConfiguration", "from spyder.plugins.help.widgets import ObjectComboBox", "from spyder.plugins.help.tests.test_plugin import check_text", "from spyder.plugins.ipythonconsole.utils.kernel_handler import KernelHandler", "from spyder.plugins.ipythonconsole.api import (", "from spyder.plugins.mainmenu.api import ApplicationMenus", "from spyder.plugins.layout.layouts import DefaultLayouts", "from spyder.plugins.toolbar.api import ApplicationToolbars", "from spyder.plugins.run.api import (", "from spyder.py3compat import qbytearray_to_str, to_text_string", "from spyder.utils.environ import set_user_env", "from spyder.utils.misc import remove_backslashes, rename_file", "from spyder.utils.clipboard_helper import CLIPBOARD_HELPER", "from spyder.utils.programs import find_program", "from spyder.widgets.dock import DockTitleBar", "\"import sys\\n\"", "\"from spyder.utils.external import lockfile\\n\"", "shell.execute('import numpy as np; A=np.full(16, np.nan)')", "shell.execute('import numpy as np')", "(\"import numpy as np\", \"An array object of arbitrary homogeneous items\")])", "shell.execute('import os; current_dir = os.getcwd()')", "shell.execute('import os; current_dir = os.getcwd()')", "shell.execute(\"import sys; import os; \"", "shell.execute(\"import sys; import os; \"", "qtbot.keyClicks(control, 'import os; os.getcwd()')", "shell.execute((\"import matplotlib.pyplot as plt\\n\"", "shell.execute((\"import matplotlib.pyplot as plt\\n\"", "\"import time\\n\"", "shell.execute((\"import matplotlib.pyplot as plt\\n\"", "shell.execute((\"import matplotlib.pyplot as plt\\n\"", "from spyder.widgets.collectionseditor import CollectionsEditor", "from spyder.plugins.pylint.main_widget import PylintWidgetActions", "shell.execute('def foo(): import foo')", "code = (\"import time\\n\"", "from qtpy.QtCore import Qt", "code_def = \"import qtpy.QtCore\"", "shell.execute(\"import time\\n\"", "code = (\"import time\\n\"", "cmd = 'import sys;print(sys.path)'", "code2 = (\"from tmp import a\\n\"", "code2 = (\"from tmp import a\\n\"", "'import time\\n'", "'import time\\n'", "'from file1 import f\\n'", "text = (\"import multiprocessing\\n\"", "\"import traceback\\n\"", "text = (\"import multiprocessing\\n\"", "\"import traceback\\n\"", "import multiprocessing", "import sys", "import ctypes; ctypes.string_at(0)", "\"import threading\\n\"", "'import threading\\n'", "import pprint", "shell.execute(\"import ctypes; ctypes.string_at(0)\")", "shell.execute('import time')", "shell.execute('import time')", "shell.execute(\"import sys; sys_path = sys.path\")", "shell1.execute(\"import sys; sys_path = sys.path\")", "s.execute(\"import sys; sys_path = sys.path\")" ]
646
685
# Check we went to the first breakpoint assert "2---> 2 a = 10" in control.toPlainText() # Verify that we are still debugging assert shell.is_waiting_pdb_input() # Remove breakpoint and close test file main_window.debugger.clear_all_breakpoints() main_window.editor.close_file()
test_mainwindow.py
spyder.spyder.app.tests
false
false
[ "import gc", "import os", "import os.path as osp", "from pathlib import Path", "import random", "import re", "import shutil", "import sys", "import tempfile", "from textwrap import dedent", "import time", "from unittest.mock import Mock", "import uuid", "from flaky import flaky", "import ipykernel", "from IPython.core import release as ipy_release", "from matplotlib.testing.compare import compare_images", "import nbconvert", "import numpy as np", "from numpy.testing import assert_array_equal", "from packaging.version import parse", "import pylint", "import pytest", "from qtpy import PYQT_VERSION, PYQT5", "from qtpy.QtCore import QPoint, Qt, QTimer", "from qtpy.QtGui import QImage, QTextCursor", "from qtpy.QtWidgets import QAction, QApplication, QInputDialog, QWidget", "from qtpy.QtWebEngineWidgets import WEBENGINE", "from spyder import __trouble_url__", "from spyder.api.utils import get_class_values", "from spyder.api.widgets.auxiliary_widgets import SpyderWindowWidget", "from spyder.api.plugins import Plugins", "from spyder.app.tests.conftest import (", "from spyder.config.base import (", "from spyder.config.manager import CONF", "from spyder.dependencies import DEPENDENCIES", "from spyder.plugins.debugger.api import DebuggerWidgetActions", "from spyder.plugins.externalterminal.api import ExtTerminalShConfiguration", "from spyder.plugins.help.widgets import ObjectComboBox", "from spyder.plugins.help.tests.test_plugin import check_text", "from spyder.plugins.ipythonconsole.utils.kernel_handler import KernelHandler", "from spyder.plugins.ipythonconsole.api import (", "from spyder.plugins.mainmenu.api import ApplicationMenus", "from spyder.plugins.layout.layouts import DefaultLayouts", "from spyder.plugins.toolbar.api import ApplicationToolbars", "from spyder.plugins.run.api import (", "from spyder.py3compat import qbytearray_to_str, to_text_string", "from spyder.utils.environ import set_user_env", "from spyder.utils.misc import remove_backslashes, rename_file", "from spyder.utils.clipboard_helper import CLIPBOARD_HELPER", "from spyder.utils.programs import find_program", "from spyder.widgets.dock import DockTitleBar", "\"import sys\\n\"", "\"from spyder.utils.external import lockfile\\n\"", "shell.execute('import numpy as np; A=np.full(16, np.nan)')", "shell.execute('import numpy as np')", "(\"import numpy as np\", \"An array object of arbitrary homogeneous items\")])", "shell.execute('import os; current_dir = os.getcwd()')", "shell.execute('import os; current_dir = os.getcwd()')", "shell.execute(\"import sys; import os; \"", "shell.execute(\"import sys; import os; \"", "qtbot.keyClicks(control, 'import os; os.getcwd()')", "shell.execute((\"import matplotlib.pyplot as plt\\n\"", "shell.execute((\"import matplotlib.pyplot as plt\\n\"", "\"import time\\n\"", "shell.execute((\"import matplotlib.pyplot as plt\\n\"", "shell.execute((\"import matplotlib.pyplot as plt\\n\"", "from spyder.widgets.collectionseditor import CollectionsEditor", "from spyder.plugins.pylint.main_widget import PylintWidgetActions", "shell.execute('def foo(): import foo')", "code = (\"import time\\n\"", "from qtpy.QtCore import Qt", "code_def = \"import qtpy.QtCore\"", "shell.execute(\"import time\\n\"", "code = (\"import time\\n\"", "cmd = 'import sys;print(sys.path)'", "code2 = (\"from tmp import a\\n\"", "code2 = (\"from tmp import a\\n\"", "'import time\\n'", "'import time\\n'", "'from file1 import f\\n'", "text = (\"import multiprocessing\\n\"", "\"import traceback\\n\"", "text = (\"import multiprocessing\\n\"", "\"import traceback\\n\"", "import multiprocessing", "import sys", "import ctypes; ctypes.string_at(0)", "\"import threading\\n\"", "'import threading\\n'", "import pprint", "shell.execute(\"import ctypes; ctypes.string_at(0)\")", "shell.execute('import time')", "shell.execute('import time')", "shell.execute(\"import sys; sys_path = sys.path\")", "shell1.execute(\"import sys; sys_path = sys.path\")", "s.execute(\"import sys; sys_path = sys.path\")" ]
681
689
def test_runconfig_workdir(main_window, qtbot, tmpdir): """Test runconfig workdir options.""" CONF.set('run', 'parameters', {}) # ---- Load test file ---- test_file = osp.join(LOCATION, 'script.py') main_window.editor.load(test_file) code_editor = main_window.editor.get_focus_widget() ipyconsole = main_window.ipyconsole # --- Set run options for the executor --- ipy_conf = IPythonConsolePyConfiguration( current=True, post_mortem=False, python_args_enabled=False, python_args='', clear_namespace=False, console_namespace=False) wdir_opts = WorkingDirOpts(source=WorkingDirSource.CurrentDirectory, path=None) exec_conf = RunExecutionParameters( working_dir=wdir_opts, executor_params=ipy_conf) exec_uuid = str(uuid.uuid4()) ext_exec_conf = ExtendedRunExecutionParameters( uuid=exec_uuid, name='TestConf', params=exec_conf) ipy_dict = {ipyconsole.NAME: { ('py', RunContext.File): {'params': {exec_uuid: ext_exec_conf}} }} CONF.set('run', 'parameters', ipy_dict) # --- Set run options for this file --- run_parameters = generate_run_parameters(main_window, test_file, exec_uuid) CONF.set('run', 'last_used_parameters', run_parameters)
test_mainwindow.py
spyder.spyder.app.tests
false
true
[ "import gc", "import os", "import os.path as osp", "from pathlib import Path", "import random", "import re", "import shutil", "import sys", "import tempfile", "from textwrap import dedent", "import time", "from unittest.mock import Mock", "import uuid", "from flaky import flaky", "import ipykernel", "from IPython.core import release as ipy_release", "from matplotlib.testing.compare import compare_images", "import nbconvert", "import numpy as np", "from numpy.testing import assert_array_equal", "from packaging.version import parse", "import pylint", "import pytest", "from qtpy import PYQT_VERSION, PYQT5", "from qtpy.QtCore import QPoint, Qt, QTimer", "from qtpy.QtGui import QImage, QTextCursor", "from qtpy.QtWidgets import QAction, QApplication, QInputDialog, QWidget", "from qtpy.QtWebEngineWidgets import WEBENGINE", "from spyder import __trouble_url__", "from spyder.api.utils import get_class_values", "from spyder.api.widgets.auxiliary_widgets import SpyderWindowWidget", "from spyder.api.plugins import Plugins", "from spyder.app.tests.conftest import (", "from spyder.config.base import (", "from spyder.config.manager import CONF", "from spyder.dependencies import DEPENDENCIES", "from spyder.plugins.debugger.api import DebuggerWidgetActions", "from spyder.plugins.externalterminal.api import ExtTerminalShConfiguration", "from spyder.plugins.help.widgets import ObjectComboBox", "from spyder.plugins.help.tests.test_plugin import check_text", "from spyder.plugins.ipythonconsole.utils.kernel_handler import KernelHandler", "from spyder.plugins.ipythonconsole.api import (", "from spyder.plugins.mainmenu.api import ApplicationMenus", "from spyder.plugins.layout.layouts import DefaultLayouts", "from spyder.plugins.toolbar.api import ApplicationToolbars", "from spyder.plugins.run.api import (", "from spyder.py3compat import qbytearray_to_str, to_text_string", "from spyder.utils.environ import set_user_env", "from spyder.utils.misc import remove_backslashes, rename_file", "from spyder.utils.clipboard_helper import CLIPBOARD_HELPER", "from spyder.utils.programs import find_program", "from spyder.widgets.dock import DockTitleBar", "\"import sys\\n\"", "\"from spyder.utils.external import lockfile\\n\"", "shell.execute('import numpy as np; A=np.full(16, np.nan)')", "shell.execute('import numpy as np')", "(\"import numpy as np\", \"An array object of arbitrary homogeneous items\")])", "shell.execute('import os; current_dir = os.getcwd()')", "shell.execute('import os; current_dir = os.getcwd()')", "shell.execute(\"import sys; import os; \"", "shell.execute(\"import sys; import os; \"", "qtbot.keyClicks(control, 'import os; os.getcwd()')", "shell.execute((\"import matplotlib.pyplot as plt\\n\"", "shell.execute((\"import matplotlib.pyplot as plt\\n\"", "\"import time\\n\"", "shell.execute((\"import matplotlib.pyplot as plt\\n\"", "shell.execute((\"import matplotlib.pyplot as plt\\n\"", "from spyder.widgets.collectionseditor import CollectionsEditor", "from spyder.plugins.pylint.main_widget import PylintWidgetActions", "shell.execute('def foo(): import foo')", "code = (\"import time\\n\"", "from qtpy.QtCore import Qt", "code_def = \"import qtpy.QtCore\"", "shell.execute(\"import time\\n\"", "code = (\"import time\\n\"", "cmd = 'import sys;print(sys.path)'", "code2 = (\"from tmp import a\\n\"", "code2 = (\"from tmp import a\\n\"", "'import time\\n'", "'import time\\n'", "'from file1 import f\\n'", "text = (\"import multiprocessing\\n\"", "\"import traceback\\n\"", "text = (\"import multiprocessing\\n\"", "\"import traceback\\n\"", "import multiprocessing", "import sys", "import ctypes; ctypes.string_at(0)", "\"import threading\\n\"", "'import threading\\n'", "import pprint", "shell.execute(\"import ctypes; ctypes.string_at(0)\")", "shell.execute('import time')", "shell.execute('import time')", "shell.execute(\"import sys; sys_path = sys.path\")", "shell1.execute(\"import sys; sys_path = sys.path\")", "s.execute(\"import sys; sys_path = sys.path\")" ]
695
727
# --- Set run options for this file --- run_parameters = generate_run_parameters(main_window, test_file, exec_uuid) CONF.set('run', 'last_used_parameters', run_parameters) # --- Run test file --- shell = main_window.ipyconsole.get_current_shellwidget() qtbot.waitUntil( lambda: shell.spyder_kernel_ready and shell._prompt_html is not None, timeout=SHELL_TIMEOUT) qtbot.keyClick(code_editor, Qt.Key_F5) qtbot.wait(500) # --- Assert we're in cwd after execution --- with qtbot.waitSignal(shell.executed): shell.execute('import os; current_dir = os.getcwd()') assert shell.get_value('current_dir') == get_home_dir() # --- Use fixed execution dir for test file --- temp_dir = str(tmpdir.mkdir("test_dir")) wdir_opts = WorkingDirOpts(source=WorkingDirSource.CustomDirectory, path=temp_dir) exec_conf = RunExecutionParameters( working_dir=wdir_opts, executor_params=ipy_conf) ext_exec_conf['params'] = exec_conf ipy_dict = {ipyconsole.NAME: { ('py', RunContext.File): {'params': {exec_uuid: ext_exec_conf}} }} CONF.set('run', 'parameters', ipy_dict) # --- Run test file --- shell = main_window.ipyconsole.get_current_shellwidget() qtbot.waitUntil( lambda: shell.spyder_kernel_ready and shell._prompt_html is not None, timeout=SHELL_TIMEOUT) qtbot.keyClick(code_editor, Qt.Key_F5) qtbot.wait(500)
test_mainwindow.py
spyder.spyder.app.tests
false
false
[ "import gc", "import os", "import os.path as osp", "from pathlib import Path", "import random", "import re", "import shutil", "import sys", "import tempfile", "from textwrap import dedent", "import time", "from unittest.mock import Mock", "import uuid", "from flaky import flaky", "import ipykernel", "from IPython.core import release as ipy_release", "from matplotlib.testing.compare import compare_images", "import nbconvert", "import numpy as np", "from numpy.testing import assert_array_equal", "from packaging.version import parse", "import pylint", "import pytest", "from qtpy import PYQT_VERSION, PYQT5", "from qtpy.QtCore import QPoint, Qt, QTimer", "from qtpy.QtGui import QImage, QTextCursor", "from qtpy.QtWidgets import QAction, QApplication, QInputDialog, QWidget", "from qtpy.QtWebEngineWidgets import WEBENGINE", "from spyder import __trouble_url__", "from spyder.api.utils import get_class_values", "from spyder.api.widgets.auxiliary_widgets import SpyderWindowWidget", "from spyder.api.plugins import Plugins", "from spyder.app.tests.conftest import (", "from spyder.config.base import (", "from spyder.config.manager import CONF", "from spyder.dependencies import DEPENDENCIES", "from spyder.plugins.debugger.api import DebuggerWidgetActions", "from spyder.plugins.externalterminal.api import ExtTerminalShConfiguration", "from spyder.plugins.help.widgets import ObjectComboBox", "from spyder.plugins.help.tests.test_plugin import check_text", "from spyder.plugins.ipythonconsole.utils.kernel_handler import KernelHandler", "from spyder.plugins.ipythonconsole.api import (", "from spyder.plugins.mainmenu.api import ApplicationMenus", "from spyder.plugins.layout.layouts import DefaultLayouts", "from spyder.plugins.toolbar.api import ApplicationToolbars", "from spyder.plugins.run.api import (", "from spyder.py3compat import qbytearray_to_str, to_text_string", "from spyder.utils.environ import set_user_env", "from spyder.utils.misc import remove_backslashes, rename_file", "from spyder.utils.clipboard_helper import CLIPBOARD_HELPER", "from spyder.utils.programs import find_program", "from spyder.widgets.dock import DockTitleBar", "\"import sys\\n\"", "\"from spyder.utils.external import lockfile\\n\"", "shell.execute('import numpy as np; A=np.full(16, np.nan)')", "shell.execute('import numpy as np')", "(\"import numpy as np\", \"An array object of arbitrary homogeneous items\")])", "shell.execute('import os; current_dir = os.getcwd()')", "shell.execute('import os; current_dir = os.getcwd()')", "shell.execute(\"import sys; import os; \"", "shell.execute(\"import sys; import os; \"", "qtbot.keyClicks(control, 'import os; os.getcwd()')", "shell.execute((\"import matplotlib.pyplot as plt\\n\"", "shell.execute((\"import matplotlib.pyplot as plt\\n\"", "\"import time\\n\"", "shell.execute((\"import matplotlib.pyplot as plt\\n\"", "shell.execute((\"import matplotlib.pyplot as plt\\n\"", "from spyder.widgets.collectionseditor import CollectionsEditor", "from spyder.plugins.pylint.main_widget import PylintWidgetActions", "shell.execute('def foo(): import foo')", "code = (\"import time\\n\"", "from qtpy.QtCore import Qt", "code_def = \"import qtpy.QtCore\"", "shell.execute(\"import time\\n\"", "code = (\"import time\\n\"", "cmd = 'import sys;print(sys.path)'", "code2 = (\"from tmp import a\\n\"", "code2 = (\"from tmp import a\\n\"", "'import time\\n'", "'import time\\n'", "'from file1 import f\\n'", "text = (\"import multiprocessing\\n\"", "\"import traceback\\n\"", "text = (\"import multiprocessing\\n\"", "\"import traceback\\n\"", "import multiprocessing", "import sys", "import ctypes; ctypes.string_at(0)", "\"import threading\\n\"", "'import threading\\n'", "import pprint", "shell.execute(\"import ctypes; ctypes.string_at(0)\")", "shell.execute('import time')", "shell.execute('import time')", "shell.execute(\"import sys; sys_path = sys.path\")", "shell1.execute(\"import sys; sys_path = sys.path\")", "s.execute(\"import sys; sys_path = sys.path\")" ]
725
762
# --- Assert we're in fixed dir after execution --- with qtbot.waitSignal(shell.executed): shell.execute('import os; current_dir = os.getcwd()') assert shell.get_value('current_dir') == temp_dir # ---- Closing test file and resetting config ---- main_window.editor.close_file() CONF.set('run', 'parameters', {})
test_mainwindow.py
spyder.spyder.app.tests
false
false
[ "import gc", "import os", "import os.path as osp", "from pathlib import Path", "import random", "import re", "import shutil", "import sys", "import tempfile", "from textwrap import dedent", "import time", "from unittest.mock import Mock", "import uuid", "from flaky import flaky", "import ipykernel", "from IPython.core import release as ipy_release", "from matplotlib.testing.compare import compare_images", "import nbconvert", "import numpy as np", "from numpy.testing import assert_array_equal", "from packaging.version import parse", "import pylint", "import pytest", "from qtpy import PYQT_VERSION, PYQT5", "from qtpy.QtCore import QPoint, Qt, QTimer", "from qtpy.QtGui import QImage, QTextCursor", "from qtpy.QtWidgets import QAction, QApplication, QInputDialog, QWidget", "from qtpy.QtWebEngineWidgets import WEBENGINE", "from spyder import __trouble_url__", "from spyder.api.utils import get_class_values", "from spyder.api.widgets.auxiliary_widgets import SpyderWindowWidget", "from spyder.api.plugins import Plugins", "from spyder.app.tests.conftest import (", "from spyder.config.base import (", "from spyder.config.manager import CONF", "from spyder.dependencies import DEPENDENCIES", "from spyder.plugins.debugger.api import DebuggerWidgetActions", "from spyder.plugins.externalterminal.api import ExtTerminalShConfiguration", "from spyder.plugins.help.widgets import ObjectComboBox", "from spyder.plugins.help.tests.test_plugin import check_text", "from spyder.plugins.ipythonconsole.utils.kernel_handler import KernelHandler", "from spyder.plugins.ipythonconsole.api import (", "from spyder.plugins.mainmenu.api import ApplicationMenus", "from spyder.plugins.layout.layouts import DefaultLayouts", "from spyder.plugins.toolbar.api import ApplicationToolbars", "from spyder.plugins.run.api import (", "from spyder.py3compat import qbytearray_to_str, to_text_string", "from spyder.utils.environ import set_user_env", "from spyder.utils.misc import remove_backslashes, rename_file", "from spyder.utils.clipboard_helper import CLIPBOARD_HELPER", "from spyder.utils.programs import find_program", "from spyder.widgets.dock import DockTitleBar", "\"import sys\\n\"", "\"from spyder.utils.external import lockfile\\n\"", "shell.execute('import numpy as np; A=np.full(16, np.nan)')", "shell.execute('import numpy as np')", "(\"import numpy as np\", \"An array object of arbitrary homogeneous items\")])", "shell.execute('import os; current_dir = os.getcwd()')", "shell.execute('import os; current_dir = os.getcwd()')", "shell.execute(\"import sys; import os; \"", "shell.execute(\"import sys; import os; \"", "qtbot.keyClicks(control, 'import os; os.getcwd()')", "shell.execute((\"import matplotlib.pyplot as plt\\n\"", "shell.execute((\"import matplotlib.pyplot as plt\\n\"", "\"import time\\n\"", "shell.execute((\"import matplotlib.pyplot as plt\\n\"", "shell.execute((\"import matplotlib.pyplot as plt\\n\"", "from spyder.widgets.collectionseditor import CollectionsEditor", "from spyder.plugins.pylint.main_widget import PylintWidgetActions", "shell.execute('def foo(): import foo')", "code = (\"import time\\n\"", "from qtpy.QtCore import Qt", "code_def = \"import qtpy.QtCore\"", "shell.execute(\"import time\\n\"", "code = (\"import time\\n\"", "cmd = 'import sys;print(sys.path)'", "code2 = (\"from tmp import a\\n\"", "code2 = (\"from tmp import a\\n\"", "'import time\\n'", "'import time\\n'", "'from file1 import f\\n'", "text = (\"import multiprocessing\\n\"", "\"import traceback\\n\"", "text = (\"import multiprocessing\\n\"", "\"import traceback\\n\"", "import multiprocessing", "import sys", "import ctypes; ctypes.string_at(0)", "\"import threading\\n\"", "'import threading\\n'", "import pprint", "shell.execute(\"import ctypes; ctypes.string_at(0)\")", "shell.execute('import time')", "shell.execute('import time')", "shell.execute(\"import sys; sys_path = sys.path\")", "shell1.execute(\"import sys; sys_path = sys.path\")", "s.execute(\"import sys; sys_path = sys.path\")" ]
764
771
def test_dedicated_consoles(main_window, qtbot): """Test running code in dedicated consoles.""" # ---- Load test file ---- test_file = osp.join(LOCATION, 'script.py') main_window.editor.load(test_file) code_editor = main_window.editor.get_focus_widget() ipyconsole = main_window.ipyconsole # --- Set run options for the executor --- ipy_conf = IPythonConsolePyConfiguration( current=False, post_mortem=False, python_args_enabled=False, python_args='', clear_namespace=False, console_namespace=False) wdir_opts = WorkingDirOpts(source=WorkingDirSource.ConfigurationDirectory, path=None) exec_conf = RunExecutionParameters( working_dir=wdir_opts, executor_params=ipy_conf) exec_uuid = str(uuid.uuid4()) ext_exec_conf = ExtendedRunExecutionParameters( uuid=exec_uuid, name='TestConf', params=exec_conf) ipy_dict = {ipyconsole.NAME: { ('py', RunContext.File): {'params': {exec_uuid: ext_exec_conf}} }} CONF.set('run', 'parameters', ipy_dict) # --- Set run options for this file --- run_parameters = generate_run_parameters(main_window, test_file, exec_uuid) CONF.set('run', 'last_used_parameters', run_parameters)
test_mainwindow.py
spyder.spyder.app.tests
false
true
[ "import gc", "import os", "import os.path as osp", "from pathlib import Path", "import random", "import re", "import shutil", "import sys", "import tempfile", "from textwrap import dedent", "import time", "from unittest.mock import Mock", "import uuid", "from flaky import flaky", "import ipykernel", "from IPython.core import release as ipy_release", "from matplotlib.testing.compare import compare_images", "import nbconvert", "import numpy as np", "from numpy.testing import assert_array_equal", "from packaging.version import parse", "import pylint", "import pytest", "from qtpy import PYQT_VERSION, PYQT5", "from qtpy.QtCore import QPoint, Qt, QTimer", "from qtpy.QtGui import QImage, QTextCursor", "from qtpy.QtWidgets import QAction, QApplication, QInputDialog, QWidget", "from qtpy.QtWebEngineWidgets import WEBENGINE", "from spyder import __trouble_url__", "from spyder.api.utils import get_class_values", "from spyder.api.widgets.auxiliary_widgets import SpyderWindowWidget", "from spyder.api.plugins import Plugins", "from spyder.app.tests.conftest import (", "from spyder.config.base import (", "from spyder.config.manager import CONF", "from spyder.dependencies import DEPENDENCIES", "from spyder.plugins.debugger.api import DebuggerWidgetActions", "from spyder.plugins.externalterminal.api import ExtTerminalShConfiguration", "from spyder.plugins.help.widgets import ObjectComboBox", "from spyder.plugins.help.tests.test_plugin import check_text", "from spyder.plugins.ipythonconsole.utils.kernel_handler import KernelHandler", "from spyder.plugins.ipythonconsole.api import (", "from spyder.plugins.mainmenu.api import ApplicationMenus", "from spyder.plugins.layout.layouts import DefaultLayouts", "from spyder.plugins.toolbar.api import ApplicationToolbars", "from spyder.plugins.run.api import (", "from spyder.py3compat import qbytearray_to_str, to_text_string", "from spyder.utils.environ import set_user_env", "from spyder.utils.misc import remove_backslashes, rename_file", "from spyder.utils.clipboard_helper import CLIPBOARD_HELPER", "from spyder.utils.programs import find_program", "from spyder.widgets.dock import DockTitleBar", "\"import sys\\n\"", "\"from spyder.utils.external import lockfile\\n\"", "shell.execute('import numpy as np; A=np.full(16, np.nan)')", "shell.execute('import numpy as np')", "(\"import numpy as np\", \"An array object of arbitrary homogeneous items\")])", "shell.execute('import os; current_dir = os.getcwd()')", "shell.execute('import os; current_dir = os.getcwd()')", "shell.execute(\"import sys; import os; \"", "shell.execute(\"import sys; import os; \"", "qtbot.keyClicks(control, 'import os; os.getcwd()')", "shell.execute((\"import matplotlib.pyplot as plt\\n\"", "shell.execute((\"import matplotlib.pyplot as plt\\n\"", "\"import time\\n\"", "shell.execute((\"import matplotlib.pyplot as plt\\n\"", "shell.execute((\"import matplotlib.pyplot as plt\\n\"", "from spyder.widgets.collectionseditor import CollectionsEditor", "from spyder.plugins.pylint.main_widget import PylintWidgetActions", "shell.execute('def foo(): import foo')", "code = (\"import time\\n\"", "from qtpy.QtCore import Qt", "code_def = \"import qtpy.QtCore\"", "shell.execute(\"import time\\n\"", "code = (\"import time\\n\"", "cmd = 'import sys;print(sys.path)'", "code2 = (\"from tmp import a\\n\"", "code2 = (\"from tmp import a\\n\"", "'import time\\n'", "'import time\\n'", "'from file1 import f\\n'", "text = (\"import multiprocessing\\n\"", "\"import traceback\\n\"", "text = (\"import multiprocessing\\n\"", "\"import traceback\\n\"", "import multiprocessing", "import sys", "import ctypes; ctypes.string_at(0)", "\"import threading\\n\"", "'import threading\\n'", "import pprint", "shell.execute(\"import ctypes; ctypes.string_at(0)\")", "shell.execute('import time')", "shell.execute('import time')", "shell.execute(\"import sys; sys_path = sys.path\")", "shell1.execute(\"import sys; sys_path = sys.path\")", "s.execute(\"import sys; sys_path = sys.path\")" ]
779
810
# --- Set run options for this file --- run_parameters = generate_run_parameters(main_window, test_file, exec_uuid) CONF.set('run', 'last_used_parameters', run_parameters) # --- Run test file and assert that we get a dedicated console --- qtbot.keyClick(code_editor, Qt.Key_F5) qtbot.wait(500) shell = main_window.ipyconsole.get_current_shellwidget() control = shell._control qtbot.waitUntil( lambda: shell.spyder_kernel_ready and shell._prompt_html is not None, timeout=SHELL_TIMEOUT) nsb = main_window.variableexplorer.current_widget() assert len(main_window.ipyconsole.get_clients()) == 2 assert main_window.ipyconsole.get_widget().filenames == ['', test_file] assert main_window.ipyconsole.get_widget().tabwidget.tabText(1) == 'script.py/A' qtbot.waitUntil(lambda: nsb.editor.source_model.rowCount() == 4) assert nsb.editor.source_model.rowCount() == 4 # --- Assert only runfile text is present and there's no banner text --- # See spyder-ide/spyder#5301. text = control.toPlainText() assert ('runfile' in text) and not ('Python' in text or 'IPython' in text) # --- Check namespace retention after re-execution --- with qtbot.waitSignal(shell.executed): shell.execute('zz = -1') qtbot.keyClick(code_editor, Qt.Key_F5) qtbot.waitUntil(lambda: shell.is_defined('zz')) assert shell.is_defined('zz')
test_mainwindow.py
spyder.spyder.app.tests
false
false
[ "import gc", "import os", "import os.path as osp", "from pathlib import Path", "import random", "import re", "import shutil", "import sys", "import tempfile", "from textwrap import dedent", "import time", "from unittest.mock import Mock", "import uuid", "from flaky import flaky", "import ipykernel", "from IPython.core import release as ipy_release", "from matplotlib.testing.compare import compare_images", "import nbconvert", "import numpy as np", "from numpy.testing import assert_array_equal", "from packaging.version import parse", "import pylint", "import pytest", "from qtpy import PYQT_VERSION, PYQT5", "from qtpy.QtCore import QPoint, Qt, QTimer", "from qtpy.QtGui import QImage, QTextCursor", "from qtpy.QtWidgets import QAction, QApplication, QInputDialog, QWidget", "from qtpy.QtWebEngineWidgets import WEBENGINE", "from spyder import __trouble_url__", "from spyder.api.utils import get_class_values", "from spyder.api.widgets.auxiliary_widgets import SpyderWindowWidget", "from spyder.api.plugins import Plugins", "from spyder.app.tests.conftest import (", "from spyder.config.base import (", "from spyder.config.manager import CONF", "from spyder.dependencies import DEPENDENCIES", "from spyder.plugins.debugger.api import DebuggerWidgetActions", "from spyder.plugins.externalterminal.api import ExtTerminalShConfiguration", "from spyder.plugins.help.widgets import ObjectComboBox", "from spyder.plugins.help.tests.test_plugin import check_text", "from spyder.plugins.ipythonconsole.utils.kernel_handler import KernelHandler", "from spyder.plugins.ipythonconsole.api import (", "from spyder.plugins.mainmenu.api import ApplicationMenus", "from spyder.plugins.layout.layouts import DefaultLayouts", "from spyder.plugins.toolbar.api import ApplicationToolbars", "from spyder.plugins.run.api import (", "from spyder.py3compat import qbytearray_to_str, to_text_string", "from spyder.utils.environ import set_user_env", "from spyder.utils.misc import remove_backslashes, rename_file", "from spyder.utils.clipboard_helper import CLIPBOARD_HELPER", "from spyder.utils.programs import find_program", "from spyder.widgets.dock import DockTitleBar", "\"import sys\\n\"", "\"from spyder.utils.external import lockfile\\n\"", "shell.execute('import numpy as np; A=np.full(16, np.nan)')", "shell.execute('import numpy as np')", "(\"import numpy as np\", \"An array object of arbitrary homogeneous items\")])", "shell.execute('import os; current_dir = os.getcwd()')", "shell.execute('import os; current_dir = os.getcwd()')", "shell.execute(\"import sys; import os; \"", "shell.execute(\"import sys; import os; \"", "qtbot.keyClicks(control, 'import os; os.getcwd()')", "shell.execute((\"import matplotlib.pyplot as plt\\n\"", "shell.execute((\"import matplotlib.pyplot as plt\\n\"", "\"import time\\n\"", "shell.execute((\"import matplotlib.pyplot as plt\\n\"", "shell.execute((\"import matplotlib.pyplot as plt\\n\"", "from spyder.widgets.collectionseditor import CollectionsEditor", "from spyder.plugins.pylint.main_widget import PylintWidgetActions", "shell.execute('def foo(): import foo')", "code = (\"import time\\n\"", "from qtpy.QtCore import Qt", "code_def = \"import qtpy.QtCore\"", "shell.execute(\"import time\\n\"", "code = (\"import time\\n\"", "cmd = 'import sys;print(sys.path)'", "code2 = (\"from tmp import a\\n\"", "code2 = (\"from tmp import a\\n\"", "'import time\\n'", "'import time\\n'", "'from file1 import f\\n'", "text = (\"import multiprocessing\\n\"", "\"import traceback\\n\"", "text = (\"import multiprocessing\\n\"", "\"import traceback\\n\"", "import multiprocessing", "import sys", "import ctypes; ctypes.string_at(0)", "\"import threading\\n\"", "'import threading\\n'", "import pprint", "shell.execute(\"import ctypes; ctypes.string_at(0)\")", "shell.execute('import time')", "shell.execute('import time')", "shell.execute(\"import sys; sys_path = sys.path\")", "shell1.execute(\"import sys; sys_path = sys.path\")", "s.execute(\"import sys; sys_path = sys.path\")" ]
725
757
qtbot.keyClick(code_editor, Qt.Key_F5) qtbot.waitUntil(lambda: shell.is_defined('zz')) assert shell.is_defined('zz') # --- Assert runfile text is present after reruns --- assert 'runfile' in control.toPlainText() # --- Clean namespace after re-execution with clear_namespace --- ipy_conf['clear_namespace'] = True CONF.set('run', 'parameters', ipy_dict) qtbot.wait(500) qtbot.keyClick(code_editor, Qt.Key_F5) qtbot.waitUntil(lambda: not shell.is_defined('zz')) assert not shell.is_defined('zz') # --- Assert runfile text is present after reruns --- assert 'runfile' in control.toPlainText() # ---- Closing test file and resetting config ---- main_window.editor.close_file() CONF.set('run', 'configurations', {}) CONF.set('run', 'last_used_parameters', {})
test_mainwindow.py
spyder.spyder.app.tests
false
false
[ "import gc", "import os", "import os.path as osp", "from pathlib import Path", "import random", "import re", "import shutil", "import sys", "import tempfile", "from textwrap import dedent", "import time", "from unittest.mock import Mock", "import uuid", "from flaky import flaky", "import ipykernel", "from IPython.core import release as ipy_release", "from matplotlib.testing.compare import compare_images", "import nbconvert", "import numpy as np", "from numpy.testing import assert_array_equal", "from packaging.version import parse", "import pylint", "import pytest", "from qtpy import PYQT_VERSION, PYQT5", "from qtpy.QtCore import QPoint, Qt, QTimer", "from qtpy.QtGui import QImage, QTextCursor", "from qtpy.QtWidgets import QAction, QApplication, QInputDialog, QWidget", "from qtpy.QtWebEngineWidgets import WEBENGINE", "from spyder import __trouble_url__", "from spyder.api.utils import get_class_values", "from spyder.api.widgets.auxiliary_widgets import SpyderWindowWidget", "from spyder.api.plugins import Plugins", "from spyder.app.tests.conftest import (", "from spyder.config.base import (", "from spyder.config.manager import CONF", "from spyder.dependencies import DEPENDENCIES", "from spyder.plugins.debugger.api import DebuggerWidgetActions", "from spyder.plugins.externalterminal.api import ExtTerminalShConfiguration", "from spyder.plugins.help.widgets import ObjectComboBox", "from spyder.plugins.help.tests.test_plugin import check_text", "from spyder.plugins.ipythonconsole.utils.kernel_handler import KernelHandler", "from spyder.plugins.ipythonconsole.api import (", "from spyder.plugins.mainmenu.api import ApplicationMenus", "from spyder.plugins.layout.layouts import DefaultLayouts", "from spyder.plugins.toolbar.api import ApplicationToolbars", "from spyder.plugins.run.api import (", "from spyder.py3compat import qbytearray_to_str, to_text_string", "from spyder.utils.environ import set_user_env", "from spyder.utils.misc import remove_backslashes, rename_file", "from spyder.utils.clipboard_helper import CLIPBOARD_HELPER", "from spyder.utils.programs import find_program", "from spyder.widgets.dock import DockTitleBar", "\"import sys\\n\"", "\"from spyder.utils.external import lockfile\\n\"", "shell.execute('import numpy as np; A=np.full(16, np.nan)')", "shell.execute('import numpy as np')", "(\"import numpy as np\", \"An array object of arbitrary homogeneous items\")])", "shell.execute('import os; current_dir = os.getcwd()')", "shell.execute('import os; current_dir = os.getcwd()')", "shell.execute(\"import sys; import os; \"", "shell.execute(\"import sys; import os; \"", "qtbot.keyClicks(control, 'import os; os.getcwd()')", "shell.execute((\"import matplotlib.pyplot as plt\\n\"", "shell.execute((\"import matplotlib.pyplot as plt\\n\"", "\"import time\\n\"", "shell.execute((\"import matplotlib.pyplot as plt\\n\"", "shell.execute((\"import matplotlib.pyplot as plt\\n\"", "from spyder.widgets.collectionseditor import CollectionsEditor", "from spyder.plugins.pylint.main_widget import PylintWidgetActions", "shell.execute('def foo(): import foo')", "code = (\"import time\\n\"", "from qtpy.QtCore import Qt", "code_def = \"import qtpy.QtCore\"", "shell.execute(\"import time\\n\"", "code = (\"import time\\n\"", "cmd = 'import sys;print(sys.path)'", "code2 = (\"from tmp import a\\n\"", "code2 = (\"from tmp import a\\n\"", "'import time\\n'", "'import time\\n'", "'from file1 import f\\n'", "text = (\"import multiprocessing\\n\"", "\"import traceback\\n\"", "text = (\"import multiprocessing\\n\"", "\"import traceback\\n\"", "import multiprocessing", "import sys", "import ctypes; ctypes.string_at(0)", "\"import threading\\n\"", "'import threading\\n'", "import pprint", "shell.execute(\"import ctypes; ctypes.string_at(0)\")", "shell.execute('import time')", "shell.execute('import time')", "shell.execute(\"import sys; sys_path = sys.path\")", "shell1.execute(\"import sys; sys_path = sys.path\")", "s.execute(\"import sys; sys_path = sys.path\")" ]
838
860
def test_shell_execution(main_window, qtbot, tmpdir): """Test that bash/batch files can be executed.""" ext = 'sh' script = 'bash_example.sh' interpreter = 'bash' opts = '' if sys.platform == 'darwin': interpreter = 'zsh' elif os.name == 'nt': interpreter = find_program('cmd.exe') script = 'batch_example.bat' ext = 'bat' opts = '/K' # ---- Wait for the ipython console to be ready ---- # This helps to give time to process all startup events before adding # more things. shell = main_window.ipyconsole.get_current_shellwidget() qtbot.waitUntil( lambda: shell.spyder_kernel_ready and shell._prompt_html is not None, timeout=SHELL_TIMEOUT) # ---- Load test file ---- test_file = osp.join(LOCATION, script) main_window.editor.load(test_file) code_editor = main_window.editor.get_focus_widget() external_terminal = main_window.external_terminal temp_dir = str(tmpdir.mkdir("test_dir")) # --- Set run options for the executor --- ext_conf = ExtTerminalShConfiguration( interpreter=interpreter, interpreter_opts_enabled=False, interpreter_opts=opts, script_opts_enabled=True, script_opts=temp_dir, close_after_exec=True) wdir_opts = WorkingDirOpts(source=WorkingDirSource.ConfigurationDirectory, path=None) exec_conf = RunExecutionParameters( working_dir=wdir_opts, executor_params=ext_conf)
test_mainwindow.py
spyder.spyder.app.tests
false
true
[ "import gc", "import os", "import os.path as osp", "from pathlib import Path", "import random", "import re", "import shutil", "import sys", "import tempfile", "from textwrap import dedent", "import time", "from unittest.mock import Mock", "import uuid", "from flaky import flaky", "import ipykernel", "from IPython.core import release as ipy_release", "from matplotlib.testing.compare import compare_images", "import nbconvert", "import numpy as np", "from numpy.testing import assert_array_equal", "from packaging.version import parse", "import pylint", "import pytest", "from qtpy import PYQT_VERSION, PYQT5", "from qtpy.QtCore import QPoint, Qt, QTimer", "from qtpy.QtGui import QImage, QTextCursor", "from qtpy.QtWidgets import QAction, QApplication, QInputDialog, QWidget", "from qtpy.QtWebEngineWidgets import WEBENGINE", "from spyder import __trouble_url__", "from spyder.api.utils import get_class_values", "from spyder.api.widgets.auxiliary_widgets import SpyderWindowWidget", "from spyder.api.plugins import Plugins", "from spyder.app.tests.conftest import (", "from spyder.config.base import (", "from spyder.config.manager import CONF", "from spyder.dependencies import DEPENDENCIES", "from spyder.plugins.debugger.api import DebuggerWidgetActions", "from spyder.plugins.externalterminal.api import ExtTerminalShConfiguration", "from spyder.plugins.help.widgets import ObjectComboBox", "from spyder.plugins.help.tests.test_plugin import check_text", "from spyder.plugins.ipythonconsole.utils.kernel_handler import KernelHandler", "from spyder.plugins.ipythonconsole.api import (", "from spyder.plugins.mainmenu.api import ApplicationMenus", "from spyder.plugins.layout.layouts import DefaultLayouts", "from spyder.plugins.toolbar.api import ApplicationToolbars", "from spyder.plugins.run.api import (", "from spyder.py3compat import qbytearray_to_str, to_text_string", "from spyder.utils.environ import set_user_env", "from spyder.utils.misc import remove_backslashes, rename_file", "from spyder.utils.clipboard_helper import CLIPBOARD_HELPER", "from spyder.utils.programs import find_program", "from spyder.widgets.dock import DockTitleBar", "\"import sys\\n\"", "\"from spyder.utils.external import lockfile\\n\"", "shell.execute('import numpy as np; A=np.full(16, np.nan)')", "shell.execute('import numpy as np')", "(\"import numpy as np\", \"An array object of arbitrary homogeneous items\")])", "shell.execute('import os; current_dir = os.getcwd()')", "shell.execute('import os; current_dir = os.getcwd()')", "shell.execute(\"import sys; import os; \"", "shell.execute(\"import sys; import os; \"", "qtbot.keyClicks(control, 'import os; os.getcwd()')", "shell.execute((\"import matplotlib.pyplot as plt\\n\"", "shell.execute((\"import matplotlib.pyplot as plt\\n\"", "\"import time\\n\"", "shell.execute((\"import matplotlib.pyplot as plt\\n\"", "shell.execute((\"import matplotlib.pyplot as plt\\n\"", "from spyder.widgets.collectionseditor import CollectionsEditor", "from spyder.plugins.pylint.main_widget import PylintWidgetActions", "shell.execute('def foo(): import foo')", "code = (\"import time\\n\"", "from qtpy.QtCore import Qt", "code_def = \"import qtpy.QtCore\"", "shell.execute(\"import time\\n\"", "code = (\"import time\\n\"", "cmd = 'import sys;print(sys.path)'", "code2 = (\"from tmp import a\\n\"", "code2 = (\"from tmp import a\\n\"", "'import time\\n'", "'import time\\n'", "'from file1 import f\\n'", "text = (\"import multiprocessing\\n\"", "\"import traceback\\n\"", "text = (\"import multiprocessing\\n\"", "\"import traceback\\n\"", "import multiprocessing", "import sys", "import ctypes; ctypes.string_at(0)", "\"import threading\\n\"", "'import threading\\n'", "import pprint", "shell.execute(\"import ctypes; ctypes.string_at(0)\")", "shell.execute('import time')", "shell.execute('import time')", "shell.execute(\"import sys; sys_path = sys.path\")", "shell1.execute(\"import sys; sys_path = sys.path\")", "s.execute(\"import sys; sys_path = sys.path\")" ]
865
905
exec_conf = RunExecutionParameters( working_dir=wdir_opts, executor_params=ext_conf) exec_uuid = str(uuid.uuid4()) ext_exec_conf = ExtendedRunExecutionParameters( uuid=exec_uuid, name='TestConf', params=exec_conf) ipy_dict = {external_terminal.NAME: { (ext, RunContext.File): {'params': {exec_uuid: ext_exec_conf}} }} CONF.set('run', 'parameters', ipy_dict) # --- Set run options for this file --- run_parameters = generate_run_parameters( main_window, test_file, exec_uuid, external_terminal.NAME) CONF.set('run', 'last_used_parameters', run_parameters) # --- Run test file and assert that the script gets executed --- qtbot.keyClick(code_editor, Qt.Key_F5) qtbot.wait(1000) qtbot.waitUntil(lambda: osp.exists(osp.join(temp_dir, 'output_file.txt')), timeout=EVAL_TIMEOUT) qtbot.wait(1000) with open(osp.join(temp_dir, 'output_file.txt'), 'r') as f: lines = f.read() assert lines.lower().strip().replace('"', '') == ( f'this is a temporary file created by {sys.platform}')
test_mainwindow.py
spyder.spyder.app.tests
false
false
[ "import gc", "import os", "import os.path as osp", "from pathlib import Path", "import random", "import re", "import shutil", "import sys", "import tempfile", "from textwrap import dedent", "import time", "from unittest.mock import Mock", "import uuid", "from flaky import flaky", "import ipykernel", "from IPython.core import release as ipy_release", "from matplotlib.testing.compare import compare_images", "import nbconvert", "import numpy as np", "from numpy.testing import assert_array_equal", "from packaging.version import parse", "import pylint", "import pytest", "from qtpy import PYQT_VERSION, PYQT5", "from qtpy.QtCore import QPoint, Qt, QTimer", "from qtpy.QtGui import QImage, QTextCursor", "from qtpy.QtWidgets import QAction, QApplication, QInputDialog, QWidget", "from qtpy.QtWebEngineWidgets import WEBENGINE", "from spyder import __trouble_url__", "from spyder.api.utils import get_class_values", "from spyder.api.widgets.auxiliary_widgets import SpyderWindowWidget", "from spyder.api.plugins import Plugins", "from spyder.app.tests.conftest import (", "from spyder.config.base import (", "from spyder.config.manager import CONF", "from spyder.dependencies import DEPENDENCIES", "from spyder.plugins.debugger.api import DebuggerWidgetActions", "from spyder.plugins.externalterminal.api import ExtTerminalShConfiguration", "from spyder.plugins.help.widgets import ObjectComboBox", "from spyder.plugins.help.tests.test_plugin import check_text", "from spyder.plugins.ipythonconsole.utils.kernel_handler import KernelHandler", "from spyder.plugins.ipythonconsole.api import (", "from spyder.plugins.mainmenu.api import ApplicationMenus", "from spyder.plugins.layout.layouts import DefaultLayouts", "from spyder.plugins.toolbar.api import ApplicationToolbars", "from spyder.plugins.run.api import (", "from spyder.py3compat import qbytearray_to_str, to_text_string", "from spyder.utils.environ import set_user_env", "from spyder.utils.misc import remove_backslashes, rename_file", "from spyder.utils.clipboard_helper import CLIPBOARD_HELPER", "from spyder.utils.programs import find_program", "from spyder.widgets.dock import DockTitleBar", "\"import sys\\n\"", "\"from spyder.utils.external import lockfile\\n\"", "shell.execute('import numpy as np; A=np.full(16, np.nan)')", "shell.execute('import numpy as np')", "(\"import numpy as np\", \"An array object of arbitrary homogeneous items\")])", "shell.execute('import os; current_dir = os.getcwd()')", "shell.execute('import os; current_dir = os.getcwd()')", "shell.execute(\"import sys; import os; \"", "shell.execute(\"import sys; import os; \"", "qtbot.keyClicks(control, 'import os; os.getcwd()')", "shell.execute((\"import matplotlib.pyplot as plt\\n\"", "shell.execute((\"import matplotlib.pyplot as plt\\n\"", "\"import time\\n\"", "shell.execute((\"import matplotlib.pyplot as plt\\n\"", "shell.execute((\"import matplotlib.pyplot as plt\\n\"", "from spyder.widgets.collectionseditor import CollectionsEditor", "from spyder.plugins.pylint.main_widget import PylintWidgetActions", "shell.execute('def foo(): import foo')", "code = (\"import time\\n\"", "from qtpy.QtCore import Qt", "code_def = \"import qtpy.QtCore\"", "shell.execute(\"import time\\n\"", "code = (\"import time\\n\"", "cmd = 'import sys;print(sys.path)'", "code2 = (\"from tmp import a\\n\"", "code2 = (\"from tmp import a\\n\"", "'import time\\n'", "'import time\\n'", "'from file1 import f\\n'", "text = (\"import multiprocessing\\n\"", "\"import traceback\\n\"", "text = (\"import multiprocessing\\n\"", "\"import traceback\\n\"", "import multiprocessing", "import sys", "import ctypes; ctypes.string_at(0)", "\"import threading\\n\"", "'import threading\\n'", "import pprint", "shell.execute(\"import ctypes; ctypes.string_at(0)\")", "shell.execute('import time')", "shell.execute('import time')", "shell.execute(\"import sys; sys_path = sys.path\")", "shell1.execute(\"import sys; sys_path = sys.path\")", "s.execute(\"import sys; sys_path = sys.path\")" ]
904
933
def test_connection_to_external_kernel(main_window, qtbot): """Test that only Spyder kernels are connected to the Variable Explorer.""" # Test with a generic kernel km, kc = start_new_kernel() main_window.ipyconsole.create_client_for_kernel(kc.connection_file) shell = main_window.ipyconsole.get_current_shellwidget() qtbot.waitUntil( lambda: shell._prompt_html is not None, timeout=SHELL_TIMEOUT) with qtbot.waitSignal(shell.executed): shell.execute('a = 10') # Assert that there are no variables in the variable explorer main_window.variableexplorer.change_visibility(True) nsb = main_window.variableexplorer.current_widget() qtbot.waitUntil(lambda: nsb.editor.source_model.rowCount() == 0) assert nsb.editor.source_model.rowCount() == 0 python_shell = shell # Test with a kernel from Spyder spykm, spykc = start_new_kernel(spykernel=True) main_window.ipyconsole.create_client_for_kernel(spykc.connection_file) shell = main_window.ipyconsole.get_current_shellwidget() qtbot.waitUntil( lambda: shell.spyder_kernel_ready and shell._prompt_html is not None, timeout=SHELL_TIMEOUT) with qtbot.waitSignal(shell.executed): shell.execute('a = 10')
test_mainwindow.py
spyder.spyder.app.tests
false
true
[ "import gc", "import os", "import os.path as osp", "from pathlib import Path", "import random", "import re", "import shutil", "import sys", "import tempfile", "from textwrap import dedent", "import time", "from unittest.mock import Mock", "import uuid", "from flaky import flaky", "import ipykernel", "from IPython.core import release as ipy_release", "from matplotlib.testing.compare import compare_images", "import nbconvert", "import numpy as np", "from numpy.testing import assert_array_equal", "from packaging.version import parse", "import pylint", "import pytest", "from qtpy import PYQT_VERSION, PYQT5", "from qtpy.QtCore import QPoint, Qt, QTimer", "from qtpy.QtGui import QImage, QTextCursor", "from qtpy.QtWidgets import QAction, QApplication, QInputDialog, QWidget", "from qtpy.QtWebEngineWidgets import WEBENGINE", "from spyder import __trouble_url__", "from spyder.api.utils import get_class_values", "from spyder.api.widgets.auxiliary_widgets import SpyderWindowWidget", "from spyder.api.plugins import Plugins", "from spyder.app.tests.conftest import (", "from spyder.config.base import (", "from spyder.config.manager import CONF", "from spyder.dependencies import DEPENDENCIES", "from spyder.plugins.debugger.api import DebuggerWidgetActions", "from spyder.plugins.externalterminal.api import ExtTerminalShConfiguration", "from spyder.plugins.help.widgets import ObjectComboBox", "from spyder.plugins.help.tests.test_plugin import check_text", "from spyder.plugins.ipythonconsole.utils.kernel_handler import KernelHandler", "from spyder.plugins.ipythonconsole.api import (", "from spyder.plugins.mainmenu.api import ApplicationMenus", "from spyder.plugins.layout.layouts import DefaultLayouts", "from spyder.plugins.toolbar.api import ApplicationToolbars", "from spyder.plugins.run.api import (", "from spyder.py3compat import qbytearray_to_str, to_text_string", "from spyder.utils.environ import set_user_env", "from spyder.utils.misc import remove_backslashes, rename_file", "from spyder.utils.clipboard_helper import CLIPBOARD_HELPER", "from spyder.utils.programs import find_program", "from spyder.widgets.dock import DockTitleBar", "\"import sys\\n\"", "\"from spyder.utils.external import lockfile\\n\"", "shell.execute('import numpy as np; A=np.full(16, np.nan)')", "shell.execute('import numpy as np')", "(\"import numpy as np\", \"An array object of arbitrary homogeneous items\")])", "shell.execute('import os; current_dir = os.getcwd()')", "shell.execute('import os; current_dir = os.getcwd()')", "shell.execute(\"import sys; import os; \"", "shell.execute(\"import sys; import os; \"", "qtbot.keyClicks(control, 'import os; os.getcwd()')", "shell.execute((\"import matplotlib.pyplot as plt\\n\"", "shell.execute((\"import matplotlib.pyplot as plt\\n\"", "\"import time\\n\"", "shell.execute((\"import matplotlib.pyplot as plt\\n\"", "shell.execute((\"import matplotlib.pyplot as plt\\n\"", "from spyder.widgets.collectionseditor import CollectionsEditor", "from spyder.plugins.pylint.main_widget import PylintWidgetActions", "shell.execute('def foo(): import foo')", "code = (\"import time\\n\"", "from qtpy.QtCore import Qt", "code_def = \"import qtpy.QtCore\"", "shell.execute(\"import time\\n\"", "code = (\"import time\\n\"", "cmd = 'import sys;print(sys.path)'", "code2 = (\"from tmp import a\\n\"", "code2 = (\"from tmp import a\\n\"", "'import time\\n'", "'import time\\n'", "'from file1 import f\\n'", "text = (\"import multiprocessing\\n\"", "\"import traceback\\n\"", "text = (\"import multiprocessing\\n\"", "\"import traceback\\n\"", "import multiprocessing", "import sys", "import ctypes; ctypes.string_at(0)", "\"import threading\\n\"", "'import threading\\n'", "import pprint", "shell.execute(\"import ctypes; ctypes.string_at(0)\")", "shell.execute('import time')", "shell.execute('import time')", "shell.execute(\"import sys; sys_path = sys.path\")", "shell1.execute(\"import sys; sys_path = sys.path\")", "s.execute(\"import sys; sys_path = sys.path\")" ]
940
969
# Assert that a variable is visible in the variable explorer main_window.variableexplorer.change_visibility(True) nsb = main_window.variableexplorer.current_widget() qtbot.waitUntil(lambda: nsb.editor.source_model.rowCount() == 1) assert nsb.editor.source_model.rowCount() == 1 # create new file main_window.editor.new() code_editor = main_window.editor.get_focus_widget() code_editor.set_text( "print(2 + 1)" ) file_path = main_window.editor.get_current_filename() run_parameters = generate_run_parameters(main_window, file_path) CONF.set('run', 'last_used_parameters', run_parameters) # Start running with qtbot.waitSignal(shell.executed): qtbot.mouseClick(main_window.run_button, Qt.LeftButton) assert "runfile" in shell._control.toPlainText() assert "3" in shell._control.toPlainText() # Try enabling a qt backend and debugging if os.name != 'nt': # Fails on windows with qtbot.waitSignal(shell.executed): shell.execute('%matplotlib qt5') with qtbot.waitSignal(shell.executed): shell.execute('%debug print()') with qtbot.waitSignal(shell.executed): shell.execute('1 + 1') with qtbot.waitSignal(shell.executed): shell.execute('q') # Try quitting the kernels shell.execute('quit()') python_shell.execute('quit()')
test_mainwindow.py
spyder.spyder.app.tests
false
false
[ "import gc", "import os", "import os.path as osp", "from pathlib import Path", "import random", "import re", "import shutil", "import sys", "import tempfile", "from textwrap import dedent", "import time", "from unittest.mock import Mock", "import uuid", "from flaky import flaky", "import ipykernel", "from IPython.core import release as ipy_release", "from matplotlib.testing.compare import compare_images", "import nbconvert", "import numpy as np", "from numpy.testing import assert_array_equal", "from packaging.version import parse", "import pylint", "import pytest", "from qtpy import PYQT_VERSION, PYQT5", "from qtpy.QtCore import QPoint, Qt, QTimer", "from qtpy.QtGui import QImage, QTextCursor", "from qtpy.QtWidgets import QAction, QApplication, QInputDialog, QWidget", "from qtpy.QtWebEngineWidgets import WEBENGINE", "from spyder import __trouble_url__", "from spyder.api.utils import get_class_values", "from spyder.api.widgets.auxiliary_widgets import SpyderWindowWidget", "from spyder.api.plugins import Plugins", "from spyder.app.tests.conftest import (", "from spyder.config.base import (", "from spyder.config.manager import CONF", "from spyder.dependencies import DEPENDENCIES", "from spyder.plugins.debugger.api import DebuggerWidgetActions", "from spyder.plugins.externalterminal.api import ExtTerminalShConfiguration", "from spyder.plugins.help.widgets import ObjectComboBox", "from spyder.plugins.help.tests.test_plugin import check_text", "from spyder.plugins.ipythonconsole.utils.kernel_handler import KernelHandler", "from spyder.plugins.ipythonconsole.api import (", "from spyder.plugins.mainmenu.api import ApplicationMenus", "from spyder.plugins.layout.layouts import DefaultLayouts", "from spyder.plugins.toolbar.api import ApplicationToolbars", "from spyder.plugins.run.api import (", "from spyder.py3compat import qbytearray_to_str, to_text_string", "from spyder.utils.environ import set_user_env", "from spyder.utils.misc import remove_backslashes, rename_file", "from spyder.utils.clipboard_helper import CLIPBOARD_HELPER", "from spyder.utils.programs import find_program", "from spyder.widgets.dock import DockTitleBar", "\"import sys\\n\"", "\"from spyder.utils.external import lockfile\\n\"", "shell.execute('import numpy as np; A=np.full(16, np.nan)')", "shell.execute('import numpy as np')", "(\"import numpy as np\", \"An array object of arbitrary homogeneous items\")])", "shell.execute('import os; current_dir = os.getcwd()')", "shell.execute('import os; current_dir = os.getcwd()')", "shell.execute(\"import sys; import os; \"", "shell.execute(\"import sys; import os; \"", "qtbot.keyClicks(control, 'import os; os.getcwd()')", "shell.execute((\"import matplotlib.pyplot as plt\\n\"", "shell.execute((\"import matplotlib.pyplot as plt\\n\"", "\"import time\\n\"", "shell.execute((\"import matplotlib.pyplot as plt\\n\"", "shell.execute((\"import matplotlib.pyplot as plt\\n\"", "from spyder.widgets.collectionseditor import CollectionsEditor", "from spyder.plugins.pylint.main_widget import PylintWidgetActions", "shell.execute('def foo(): import foo')", "code = (\"import time\\n\"", "from qtpy.QtCore import Qt", "code_def = \"import qtpy.QtCore\"", "shell.execute(\"import time\\n\"", "code = (\"import time\\n\"", "cmd = 'import sys;print(sys.path)'", "code2 = (\"from tmp import a\\n\"", "code2 = (\"from tmp import a\\n\"", "'import time\\n'", "'import time\\n'", "'from file1 import f\\n'", "text = (\"import multiprocessing\\n\"", "\"import traceback\\n\"", "text = (\"import multiprocessing\\n\"", "\"import traceback\\n\"", "import multiprocessing", "import sys", "import ctypes; ctypes.string_at(0)", "\"import threading\\n\"", "'import threading\\n'", "import pprint", "shell.execute(\"import ctypes; ctypes.string_at(0)\")", "shell.execute('import time')", "shell.execute('import time')", "shell.execute(\"import sys; sys_path = sys.path\")", "shell1.execute(\"import sys; sys_path = sys.path\")", "s.execute(\"import sys; sys_path = sys.path\")" ]
971
1,009
# Try quitting the kernels shell.execute('quit()') python_shell.execute('quit()') # Make sure everything quit properly qtbot.waitUntil(lambda: not km.is_alive()) assert not km.is_alive() qtbot.waitUntil(lambda: not spykm.is_alive()) assert not spykm.is_alive() # Close the channels spykc.stop_channels() kc.stop_channels()
test_mainwindow.py
spyder.spyder.app.tests
false
false
[ "import gc", "import os", "import os.path as osp", "from pathlib import Path", "import random", "import re", "import shutil", "import sys", "import tempfile", "from textwrap import dedent", "import time", "from unittest.mock import Mock", "import uuid", "from flaky import flaky", "import ipykernel", "from IPython.core import release as ipy_release", "from matplotlib.testing.compare import compare_images", "import nbconvert", "import numpy as np", "from numpy.testing import assert_array_equal", "from packaging.version import parse", "import pylint", "import pytest", "from qtpy import PYQT_VERSION, PYQT5", "from qtpy.QtCore import QPoint, Qt, QTimer", "from qtpy.QtGui import QImage, QTextCursor", "from qtpy.QtWidgets import QAction, QApplication, QInputDialog, QWidget", "from qtpy.QtWebEngineWidgets import WEBENGINE", "from spyder import __trouble_url__", "from spyder.api.utils import get_class_values", "from spyder.api.widgets.auxiliary_widgets import SpyderWindowWidget", "from spyder.api.plugins import Plugins", "from spyder.app.tests.conftest import (", "from spyder.config.base import (", "from spyder.config.manager import CONF", "from spyder.dependencies import DEPENDENCIES", "from spyder.plugins.debugger.api import DebuggerWidgetActions", "from spyder.plugins.externalterminal.api import ExtTerminalShConfiguration", "from spyder.plugins.help.widgets import ObjectComboBox", "from spyder.plugins.help.tests.test_plugin import check_text", "from spyder.plugins.ipythonconsole.utils.kernel_handler import KernelHandler", "from spyder.plugins.ipythonconsole.api import (", "from spyder.plugins.mainmenu.api import ApplicationMenus", "from spyder.plugins.layout.layouts import DefaultLayouts", "from spyder.plugins.toolbar.api import ApplicationToolbars", "from spyder.plugins.run.api import (", "from spyder.py3compat import qbytearray_to_str, to_text_string", "from spyder.utils.environ import set_user_env", "from spyder.utils.misc import remove_backslashes, rename_file", "from spyder.utils.clipboard_helper import CLIPBOARD_HELPER", "from spyder.utils.programs import find_program", "from spyder.widgets.dock import DockTitleBar", "\"import sys\\n\"", "\"from spyder.utils.external import lockfile\\n\"", "shell.execute('import numpy as np; A=np.full(16, np.nan)')", "shell.execute('import numpy as np')", "(\"import numpy as np\", \"An array object of arbitrary homogeneous items\")])", "shell.execute('import os; current_dir = os.getcwd()')", "shell.execute('import os; current_dir = os.getcwd()')", "shell.execute(\"import sys; import os; \"", "shell.execute(\"import sys; import os; \"", "qtbot.keyClicks(control, 'import os; os.getcwd()')", "shell.execute((\"import matplotlib.pyplot as plt\\n\"", "shell.execute((\"import matplotlib.pyplot as plt\\n\"", "\"import time\\n\"", "shell.execute((\"import matplotlib.pyplot as plt\\n\"", "shell.execute((\"import matplotlib.pyplot as plt\\n\"", "from spyder.widgets.collectionseditor import CollectionsEditor", "from spyder.plugins.pylint.main_widget import PylintWidgetActions", "shell.execute('def foo(): import foo')", "code = (\"import time\\n\"", "from qtpy.QtCore import Qt", "code_def = \"import qtpy.QtCore\"", "shell.execute(\"import time\\n\"", "code = (\"import time\\n\"", "cmd = 'import sys;print(sys.path)'", "code2 = (\"from tmp import a\\n\"", "code2 = (\"from tmp import a\\n\"", "'import time\\n'", "'import time\\n'", "'from file1 import f\\n'", "text = (\"import multiprocessing\\n\"", "\"import traceback\\n\"", "text = (\"import multiprocessing\\n\"", "\"import traceback\\n\"", "import multiprocessing", "import sys", "import ctypes; ctypes.string_at(0)", "\"import threading\\n\"", "'import threading\\n'", "import pprint", "shell.execute(\"import ctypes; ctypes.string_at(0)\")", "shell.execute('import time')", "shell.execute('import time')", "shell.execute(\"import sys; sys_path = sys.path\")", "shell1.execute(\"import sys; sys_path = sys.path\")", "s.execute(\"import sys; sys_path = sys.path\")" ]
1,007
1,019
def test_change_types_in_varexp(main_window, qtbot): """Test that variable types can't be changed in the Variable Explorer.""" # Create object shell = main_window.ipyconsole.get_current_shellwidget() qtbot.waitUntil( lambda: shell.spyder_kernel_ready and shell._prompt_html is not None, timeout=SHELL_TIMEOUT) with qtbot.waitSignal(shell.executed): shell.execute('a = 10') # Edit object main_window.variableexplorer.change_visibility(True) nsb = main_window.variableexplorer.current_widget() qtbot.waitUntil( lambda: nsb.editor.source_model.rowCount() > 0, timeout=EVAL_TIMEOUT) nsb.editor.setFocus() nsb.editor.edit_item() # Try to change types qtbot.keyClicks(QApplication.focusWidget(), "'s'") qtbot.keyClick(QApplication.focusWidget(), Qt.Key_Enter) qtbot.wait(1000) # Assert object remains the same assert shell.get_value('a') == 10
test_mainwindow.py
spyder.spyder.app.tests
false
true
[ "import gc", "import os", "import os.path as osp", "from pathlib import Path", "import random", "import re", "import shutil", "import sys", "import tempfile", "from textwrap import dedent", "import time", "from unittest.mock import Mock", "import uuid", "from flaky import flaky", "import ipykernel", "from IPython.core import release as ipy_release", "from matplotlib.testing.compare import compare_images", "import nbconvert", "import numpy as np", "from numpy.testing import assert_array_equal", "from packaging.version import parse", "import pylint", "import pytest", "from qtpy import PYQT_VERSION, PYQT5", "from qtpy.QtCore import QPoint, Qt, QTimer", "from qtpy.QtGui import QImage, QTextCursor", "from qtpy.QtWidgets import QAction, QApplication, QInputDialog, QWidget", "from qtpy.QtWebEngineWidgets import WEBENGINE", "from spyder import __trouble_url__", "from spyder.api.utils import get_class_values", "from spyder.api.widgets.auxiliary_widgets import SpyderWindowWidget", "from spyder.api.plugins import Plugins", "from spyder.app.tests.conftest import (", "from spyder.config.base import (", "from spyder.config.manager import CONF", "from spyder.dependencies import DEPENDENCIES", "from spyder.plugins.debugger.api import DebuggerWidgetActions", "from spyder.plugins.externalterminal.api import ExtTerminalShConfiguration", "from spyder.plugins.help.widgets import ObjectComboBox", "from spyder.plugins.help.tests.test_plugin import check_text", "from spyder.plugins.ipythonconsole.utils.kernel_handler import KernelHandler", "from spyder.plugins.ipythonconsole.api import (", "from spyder.plugins.mainmenu.api import ApplicationMenus", "from spyder.plugins.layout.layouts import DefaultLayouts", "from spyder.plugins.toolbar.api import ApplicationToolbars", "from spyder.plugins.run.api import (", "from spyder.py3compat import qbytearray_to_str, to_text_string", "from spyder.utils.environ import set_user_env", "from spyder.utils.misc import remove_backslashes, rename_file", "from spyder.utils.clipboard_helper import CLIPBOARD_HELPER", "from spyder.utils.programs import find_program", "from spyder.widgets.dock import DockTitleBar", "\"import sys\\n\"", "\"from spyder.utils.external import lockfile\\n\"", "shell.execute('import numpy as np; A=np.full(16, np.nan)')", "shell.execute('import numpy as np')", "(\"import numpy as np\", \"An array object of arbitrary homogeneous items\")])", "shell.execute('import os; current_dir = os.getcwd()')", "shell.execute('import os; current_dir = os.getcwd()')", "shell.execute(\"import sys; import os; \"", "shell.execute(\"import sys; import os; \"", "qtbot.keyClicks(control, 'import os; os.getcwd()')", "shell.execute((\"import matplotlib.pyplot as plt\\n\"", "shell.execute((\"import matplotlib.pyplot as plt\\n\"", "\"import time\\n\"", "shell.execute((\"import matplotlib.pyplot as plt\\n\"", "shell.execute((\"import matplotlib.pyplot as plt\\n\"", "from spyder.widgets.collectionseditor import CollectionsEditor", "from spyder.plugins.pylint.main_widget import PylintWidgetActions", "shell.execute('def foo(): import foo')", "code = (\"import time\\n\"", "from qtpy.QtCore import Qt", "code_def = \"import qtpy.QtCore\"", "shell.execute(\"import time\\n\"", "code = (\"import time\\n\"", "cmd = 'import sys;print(sys.path)'", "code2 = (\"from tmp import a\\n\"", "code2 = (\"from tmp import a\\n\"", "'import time\\n'", "'import time\\n'", "'from file1 import f\\n'", "text = (\"import multiprocessing\\n\"", "\"import traceback\\n\"", "text = (\"import multiprocessing\\n\"", "\"import traceback\\n\"", "import multiprocessing", "import sys", "import ctypes; ctypes.string_at(0)", "\"import threading\\n\"", "'import threading\\n'", "import pprint", "shell.execute(\"import ctypes; ctypes.string_at(0)\")", "shell.execute('import time')", "shell.execute('import time')", "shell.execute(\"import sys; sys_path = sys.path\")", "shell1.execute(\"import sys; sys_path = sys.path\")", "s.execute(\"import sys; sys_path = sys.path\")" ]
1,026
1,050
def test_change_cwd_ipython_console( main_window, qtbot, tmpdir, test_directory): """ Test synchronization with working directory and File Explorer when changing cwd in the IPython console. """ wdir = main_window.workingdirectory treewidget = main_window.explorer.get_widget().treewidget shell = main_window.ipyconsole.get_current_shellwidget() # Wait until the window is fully up qtbot.waitUntil( lambda: shell.spyder_kernel_ready and shell._prompt_html is not None, timeout=SHELL_TIMEOUT) # Create temp dir temp_dir = str(tmpdir.mkdir(test_directory)) # Change directory in IPython console using %cd with qtbot.waitSignal(shell.executed): shell.execute(u"%cd {}".format(temp_dir)) qtbot.waitUntil( lambda: osp.normpath(wdir.get_container().history[-1]) == osp.normpath( temp_dir), timeout=SHELL_TIMEOUT) # Assert that cwd changed in workingdirectory assert osp.normpath(wdir.get_container().history[-1]) == osp.normpath( temp_dir) qtbot.waitUntil( lambda: osp.normpath(treewidget.get_current_folder()) == osp.normpath( temp_dir), timeout=SHELL_TIMEOUT) # Assert that cwd changed in explorer assert osp.normpath(treewidget.get_current_folder()) == osp.normpath( temp_dir)
test_mainwindow.py
spyder.spyder.app.tests
false
false
[ "import gc", "import os", "import os.path as osp", "from pathlib import Path", "import random", "import re", "import shutil", "import sys", "import tempfile", "from textwrap import dedent", "import time", "from unittest.mock import Mock", "import uuid", "from flaky import flaky", "import ipykernel", "from IPython.core import release as ipy_release", "from matplotlib.testing.compare import compare_images", "import nbconvert", "import numpy as np", "from numpy.testing import assert_array_equal", "from packaging.version import parse", "import pylint", "import pytest", "from qtpy import PYQT_VERSION, PYQT5", "from qtpy.QtCore import QPoint, Qt, QTimer", "from qtpy.QtGui import QImage, QTextCursor", "from qtpy.QtWidgets import QAction, QApplication, QInputDialog, QWidget", "from qtpy.QtWebEngineWidgets import WEBENGINE", "from spyder import __trouble_url__", "from spyder.api.utils import get_class_values", "from spyder.api.widgets.auxiliary_widgets import SpyderWindowWidget", "from spyder.api.plugins import Plugins", "from spyder.app.tests.conftest import (", "from spyder.config.base import (", "from spyder.config.manager import CONF", "from spyder.dependencies import DEPENDENCIES", "from spyder.plugins.debugger.api import DebuggerWidgetActions", "from spyder.plugins.externalterminal.api import ExtTerminalShConfiguration", "from spyder.plugins.help.widgets import ObjectComboBox", "from spyder.plugins.help.tests.test_plugin import check_text", "from spyder.plugins.ipythonconsole.utils.kernel_handler import KernelHandler", "from spyder.plugins.ipythonconsole.api import (", "from spyder.plugins.mainmenu.api import ApplicationMenus", "from spyder.plugins.layout.layouts import DefaultLayouts", "from spyder.plugins.toolbar.api import ApplicationToolbars", "from spyder.plugins.run.api import (", "from spyder.py3compat import qbytearray_to_str, to_text_string", "from spyder.utils.environ import set_user_env", "from spyder.utils.misc import remove_backslashes, rename_file", "from spyder.utils.clipboard_helper import CLIPBOARD_HELPER", "from spyder.utils.programs import find_program", "from spyder.widgets.dock import DockTitleBar", "\"import sys\\n\"", "\"from spyder.utils.external import lockfile\\n\"", "shell.execute('import numpy as np; A=np.full(16, np.nan)')", "shell.execute('import numpy as np')", "(\"import numpy as np\", \"An array object of arbitrary homogeneous items\")])", "shell.execute('import os; current_dir = os.getcwd()')", "shell.execute('import os; current_dir = os.getcwd()')", "shell.execute(\"import sys; import os; \"", "shell.execute(\"import sys; import os; \"", "qtbot.keyClicks(control, 'import os; os.getcwd()')", "shell.execute((\"import matplotlib.pyplot as plt\\n\"", "shell.execute((\"import matplotlib.pyplot as plt\\n\"", "\"import time\\n\"", "shell.execute((\"import matplotlib.pyplot as plt\\n\"", "shell.execute((\"import matplotlib.pyplot as plt\\n\"", "from spyder.widgets.collectionseditor import CollectionsEditor", "from spyder.plugins.pylint.main_widget import PylintWidgetActions", "shell.execute('def foo(): import foo')", "code = (\"import time\\n\"", "from qtpy.QtCore import Qt", "code_def = \"import qtpy.QtCore\"", "shell.execute(\"import time\\n\"", "code = (\"import time\\n\"", "cmd = 'import sys;print(sys.path)'", "code2 = (\"from tmp import a\\n\"", "code2 = (\"from tmp import a\\n\"", "'import time\\n'", "'import time\\n'", "'from file1 import f\\n'", "text = (\"import multiprocessing\\n\"", "\"import traceback\\n\"", "text = (\"import multiprocessing\\n\"", "\"import traceback\\n\"", "import multiprocessing", "import sys", "import ctypes; ctypes.string_at(0)", "\"import threading\\n\"", "'import threading\\n'", "import pprint", "shell.execute(\"import ctypes; ctypes.string_at(0)\")", "shell.execute('import time')", "shell.execute('import time')", "shell.execute(\"import sys; sys_path = sys.path\")", "shell1.execute(\"import sys; sys_path = sys.path\")", "s.execute(\"import sys; sys_path = sys.path\")" ]
1,056
1,092
def test_change_cwd_explorer(main_window, qtbot, tmpdir, test_directory): """ Test synchronization with working directory and IPython console when changing directories in the File Explorer. """ wdir = main_window.workingdirectory explorer = main_window.explorer shell = main_window.ipyconsole.get_current_shellwidget() # Wait until the window is fully up qtbot.waitUntil( lambda: shell.spyder_kernel_ready and shell._prompt_html is not None, timeout=SHELL_TIMEOUT) # Create temp directory temp_dir = to_text_string(tmpdir.mkdir(test_directory)) # Change directory in the explorer widget explorer.chdir(temp_dir) qtbot.waitUntil( lambda: osp.normpath(temp_dir) == osp.normpath(shell.get_cwd()) ) # Assert that cwd changed in workingdirectory assert osp.normpath(wdir.get_container().history[-1]) == osp.normpath( temp_dir) # Assert that cwd changed in IPython console assert osp.normpath(temp_dir) == osp.normpath(shell.get_cwd())
test_mainwindow.py
spyder.spyder.app.tests
false
true
[ "import gc", "import os", "import os.path as osp", "from pathlib import Path", "import random", "import re", "import shutil", "import sys", "import tempfile", "from textwrap import dedent", "import time", "from unittest.mock import Mock", "import uuid", "from flaky import flaky", "import ipykernel", "from IPython.core import release as ipy_release", "from matplotlib.testing.compare import compare_images", "import nbconvert", "import numpy as np", "from numpy.testing import assert_array_equal", "from packaging.version import parse", "import pylint", "import pytest", "from qtpy import PYQT_VERSION, PYQT5", "from qtpy.QtCore import QPoint, Qt, QTimer", "from qtpy.QtGui import QImage, QTextCursor", "from qtpy.QtWidgets import QAction, QApplication, QInputDialog, QWidget", "from qtpy.QtWebEngineWidgets import WEBENGINE", "from spyder import __trouble_url__", "from spyder.api.utils import get_class_values", "from spyder.api.widgets.auxiliary_widgets import SpyderWindowWidget", "from spyder.api.plugins import Plugins", "from spyder.app.tests.conftest import (", "from spyder.config.base import (", "from spyder.config.manager import CONF", "from spyder.dependencies import DEPENDENCIES", "from spyder.plugins.debugger.api import DebuggerWidgetActions", "from spyder.plugins.externalterminal.api import ExtTerminalShConfiguration", "from spyder.plugins.help.widgets import ObjectComboBox", "from spyder.plugins.help.tests.test_plugin import check_text", "from spyder.plugins.ipythonconsole.utils.kernel_handler import KernelHandler", "from spyder.plugins.ipythonconsole.api import (", "from spyder.plugins.mainmenu.api import ApplicationMenus", "from spyder.plugins.layout.layouts import DefaultLayouts", "from spyder.plugins.toolbar.api import ApplicationToolbars", "from spyder.plugins.run.api import (", "from spyder.py3compat import qbytearray_to_str, to_text_string", "from spyder.utils.environ import set_user_env", "from spyder.utils.misc import remove_backslashes, rename_file", "from spyder.utils.clipboard_helper import CLIPBOARD_HELPER", "from spyder.utils.programs import find_program", "from spyder.widgets.dock import DockTitleBar", "\"import sys\\n\"", "\"from spyder.utils.external import lockfile\\n\"", "shell.execute('import numpy as np; A=np.full(16, np.nan)')", "shell.execute('import numpy as np')", "(\"import numpy as np\", \"An array object of arbitrary homogeneous items\")])", "shell.execute('import os; current_dir = os.getcwd()')", "shell.execute('import os; current_dir = os.getcwd()')", "shell.execute(\"import sys; import os; \"", "shell.execute(\"import sys; import os; \"", "qtbot.keyClicks(control, 'import os; os.getcwd()')", "shell.execute((\"import matplotlib.pyplot as plt\\n\"", "shell.execute((\"import matplotlib.pyplot as plt\\n\"", "\"import time\\n\"", "shell.execute((\"import matplotlib.pyplot as plt\\n\"", "shell.execute((\"import matplotlib.pyplot as plt\\n\"", "from spyder.widgets.collectionseditor import CollectionsEditor", "from spyder.plugins.pylint.main_widget import PylintWidgetActions", "shell.execute('def foo(): import foo')", "code = (\"import time\\n\"", "from qtpy.QtCore import Qt", "code_def = \"import qtpy.QtCore\"", "shell.execute(\"import time\\n\"", "code = (\"import time\\n\"", "cmd = 'import sys;print(sys.path)'", "code2 = (\"from tmp import a\\n\"", "code2 = (\"from tmp import a\\n\"", "'import time\\n'", "'import time\\n'", "'from file1 import f\\n'", "text = (\"import multiprocessing\\n\"", "\"import traceback\\n\"", "text = (\"import multiprocessing\\n\"", "\"import traceback\\n\"", "import multiprocessing", "import sys", "import ctypes; ctypes.string_at(0)", "\"import threading\\n\"", "'import threading\\n'", "import pprint", "shell.execute(\"import ctypes; ctypes.string_at(0)\")", "shell.execute('import time')", "shell.execute('import time')", "shell.execute(\"import sys; sys_path = sys.path\")", "shell1.execute(\"import sys; sys_path = sys.path\")", "s.execute(\"import sys; sys_path = sys.path\")" ]
1,098
1,126
def test_run_cython_code(main_window, qtbot): """Test all the different ways we have to run Cython code""" # Wait until the window is fully up shell = main_window.ipyconsole.get_current_shellwidget() qtbot.waitUntil( lambda: shell.spyder_kernel_ready and shell._prompt_html is not None, timeout=SHELL_TIMEOUT) # ---- Setup ---- # Get a reference to the code editor widget code_editor = main_window.editor.get_focus_widget() # ---- Run pyx file ---- # Load test file file_path = osp.join(LOCATION, 'pyx_script.pyx') main_window.editor.load(file_path) # --- Set run options for this file --- run_parameters = generate_run_parameters(main_window, file_path) CONF.set('run', 'last_used_parameters', run_parameters) # Run file qtbot.keyClick(code_editor, Qt.Key_F5) # Get a reference to the namespace browser widget nsb = main_window.variableexplorer.current_widget() # Wait until an object appears qtbot.waitUntil(lambda: nsb.editor.source_model.rowCount() == 1, timeout=COMPILE_AND_EVAL_TIMEOUT) # Verify result shell = main_window.ipyconsole.get_current_shellwidget() assert shell.get_value('a') == 3628800 # Reset and close file reset_run_code(qtbot, shell, code_editor, nsb) main_window.editor.close_file()
test_mainwindow.py
spyder.spyder.app.tests
false
true
[ "import gc", "import os", "import os.path as osp", "from pathlib import Path", "import random", "import re", "import shutil", "import sys", "import tempfile", "from textwrap import dedent", "import time", "from unittest.mock import Mock", "import uuid", "from flaky import flaky", "import ipykernel", "from IPython.core import release as ipy_release", "from matplotlib.testing.compare import compare_images", "import nbconvert", "import numpy as np", "from numpy.testing import assert_array_equal", "from packaging.version import parse", "import pylint", "import pytest", "from qtpy import PYQT_VERSION, PYQT5", "from qtpy.QtCore import QPoint, Qt, QTimer", "from qtpy.QtGui import QImage, QTextCursor", "from qtpy.QtWidgets import QAction, QApplication, QInputDialog, QWidget", "from qtpy.QtWebEngineWidgets import WEBENGINE", "from spyder import __trouble_url__", "from spyder.api.utils import get_class_values", "from spyder.api.widgets.auxiliary_widgets import SpyderWindowWidget", "from spyder.api.plugins import Plugins", "from spyder.app.tests.conftest import (", "from spyder.config.base import (", "from spyder.config.manager import CONF", "from spyder.dependencies import DEPENDENCIES", "from spyder.plugins.debugger.api import DebuggerWidgetActions", "from spyder.plugins.externalterminal.api import ExtTerminalShConfiguration", "from spyder.plugins.help.widgets import ObjectComboBox", "from spyder.plugins.help.tests.test_plugin import check_text", "from spyder.plugins.ipythonconsole.utils.kernel_handler import KernelHandler", "from spyder.plugins.ipythonconsole.api import (", "from spyder.plugins.mainmenu.api import ApplicationMenus", "from spyder.plugins.layout.layouts import DefaultLayouts", "from spyder.plugins.toolbar.api import ApplicationToolbars", "from spyder.plugins.run.api import (", "from spyder.py3compat import qbytearray_to_str, to_text_string", "from spyder.utils.environ import set_user_env", "from spyder.utils.misc import remove_backslashes, rename_file", "from spyder.utils.clipboard_helper import CLIPBOARD_HELPER", "from spyder.utils.programs import find_program", "from spyder.widgets.dock import DockTitleBar", "\"import sys\\n\"", "\"from spyder.utils.external import lockfile\\n\"", "shell.execute('import numpy as np; A=np.full(16, np.nan)')", "shell.execute('import numpy as np')", "(\"import numpy as np\", \"An array object of arbitrary homogeneous items\")])", "shell.execute('import os; current_dir = os.getcwd()')", "shell.execute('import os; current_dir = os.getcwd()')", "shell.execute(\"import sys; import os; \"", "shell.execute(\"import sys; import os; \"", "qtbot.keyClicks(control, 'import os; os.getcwd()')", "shell.execute((\"import matplotlib.pyplot as plt\\n\"", "shell.execute((\"import matplotlib.pyplot as plt\\n\"", "\"import time\\n\"", "shell.execute((\"import matplotlib.pyplot as plt\\n\"", "shell.execute((\"import matplotlib.pyplot as plt\\n\"", "from spyder.widgets.collectionseditor import CollectionsEditor", "from spyder.plugins.pylint.main_widget import PylintWidgetActions", "shell.execute('def foo(): import foo')", "code = (\"import time\\n\"", "from qtpy.QtCore import Qt", "code_def = \"import qtpy.QtCore\"", "shell.execute(\"import time\\n\"", "code = (\"import time\\n\"", "cmd = 'import sys;print(sys.path)'", "code2 = (\"from tmp import a\\n\"", "code2 = (\"from tmp import a\\n\"", "'import time\\n'", "'import time\\n'", "'from file1 import f\\n'", "text = (\"import multiprocessing\\n\"", "\"import traceback\\n\"", "text = (\"import multiprocessing\\n\"", "\"import traceback\\n\"", "import multiprocessing", "import sys", "import ctypes; ctypes.string_at(0)", "\"import threading\\n\"", "'import threading\\n'", "import pprint", "shell.execute(\"import ctypes; ctypes.string_at(0)\")", "shell.execute('import time')", "shell.execute('import time')", "shell.execute(\"import sys; sys_path = sys.path\")", "shell1.execute(\"import sys; sys_path = sys.path\")", "s.execute(\"import sys; sys_path = sys.path\")" ]
1,135
1,172
# Reset and close file reset_run_code(qtbot, shell, code_editor, nsb) main_window.editor.close_file() # ---- Import pyx file ---- # Load test file file_path = osp.join(LOCATION, 'pyx_lib_import.py') main_window.editor.load(file_path) # --- Set run options for this file -- run_parameters = generate_run_parameters(main_window, file_path) CONF.set('run', 'last_used_parameters', run_parameters) # Run file qtbot.keyClick(code_editor, Qt.Key_F5) # Wait until all objects have appeared in the variable explorer qtbot.waitUntil(lambda: nsb.editor.source_model.rowCount() == 1, timeout=COMPILE_AND_EVAL_TIMEOUT) # Verify result assert shell.get_value('b') == 3628800 # Close file main_window.editor.close_file()
test_mainwindow.py
spyder.spyder.app.tests
false
false
[ "import gc", "import os", "import os.path as osp", "from pathlib import Path", "import random", "import re", "import shutil", "import sys", "import tempfile", "from textwrap import dedent", "import time", "from unittest.mock import Mock", "import uuid", "from flaky import flaky", "import ipykernel", "from IPython.core import release as ipy_release", "from matplotlib.testing.compare import compare_images", "import nbconvert", "import numpy as np", "from numpy.testing import assert_array_equal", "from packaging.version import parse", "import pylint", "import pytest", "from qtpy import PYQT_VERSION, PYQT5", "from qtpy.QtCore import QPoint, Qt, QTimer", "from qtpy.QtGui import QImage, QTextCursor", "from qtpy.QtWidgets import QAction, QApplication, QInputDialog, QWidget", "from qtpy.QtWebEngineWidgets import WEBENGINE", "from spyder import __trouble_url__", "from spyder.api.utils import get_class_values", "from spyder.api.widgets.auxiliary_widgets import SpyderWindowWidget", "from spyder.api.plugins import Plugins", "from spyder.app.tests.conftest import (", "from spyder.config.base import (", "from spyder.config.manager import CONF", "from spyder.dependencies import DEPENDENCIES", "from spyder.plugins.debugger.api import DebuggerWidgetActions", "from spyder.plugins.externalterminal.api import ExtTerminalShConfiguration", "from spyder.plugins.help.widgets import ObjectComboBox", "from spyder.plugins.help.tests.test_plugin import check_text", "from spyder.plugins.ipythonconsole.utils.kernel_handler import KernelHandler", "from spyder.plugins.ipythonconsole.api import (", "from spyder.plugins.mainmenu.api import ApplicationMenus", "from spyder.plugins.layout.layouts import DefaultLayouts", "from spyder.plugins.toolbar.api import ApplicationToolbars", "from spyder.plugins.run.api import (", "from spyder.py3compat import qbytearray_to_str, to_text_string", "from spyder.utils.environ import set_user_env", "from spyder.utils.misc import remove_backslashes, rename_file", "from spyder.utils.clipboard_helper import CLIPBOARD_HELPER", "from spyder.utils.programs import find_program", "from spyder.widgets.dock import DockTitleBar", "\"import sys\\n\"", "\"from spyder.utils.external import lockfile\\n\"", "shell.execute('import numpy as np; A=np.full(16, np.nan)')", "shell.execute('import numpy as np')", "(\"import numpy as np\", \"An array object of arbitrary homogeneous items\")])", "shell.execute('import os; current_dir = os.getcwd()')", "shell.execute('import os; current_dir = os.getcwd()')", "shell.execute(\"import sys; import os; \"", "shell.execute(\"import sys; import os; \"", "qtbot.keyClicks(control, 'import os; os.getcwd()')", "shell.execute((\"import matplotlib.pyplot as plt\\n\"", "shell.execute((\"import matplotlib.pyplot as plt\\n\"", "\"import time\\n\"", "shell.execute((\"import matplotlib.pyplot as plt\\n\"", "shell.execute((\"import matplotlib.pyplot as plt\\n\"", "from spyder.widgets.collectionseditor import CollectionsEditor", "from spyder.plugins.pylint.main_widget import PylintWidgetActions", "shell.execute('def foo(): import foo')", "code = (\"import time\\n\"", "from qtpy.QtCore import Qt", "code_def = \"import qtpy.QtCore\"", "shell.execute(\"import time\\n\"", "code = (\"import time\\n\"", "cmd = 'import sys;print(sys.path)'", "code2 = (\"from tmp import a\\n\"", "code2 = (\"from tmp import a\\n\"", "'import time\\n'", "'import time\\n'", "'from file1 import f\\n'", "text = (\"import multiprocessing\\n\"", "\"import traceback\\n\"", "text = (\"import multiprocessing\\n\"", "\"import traceback\\n\"", "import multiprocessing", "import sys", "import ctypes; ctypes.string_at(0)", "\"import threading\\n\"", "'import threading\\n'", "import pprint", "shell.execute(\"import ctypes; ctypes.string_at(0)\")", "shell.execute('import time')", "shell.execute('import time')", "shell.execute(\"import sys; sys_path = sys.path\")", "shell1.execute(\"import sys; sys_path = sys.path\")", "s.execute(\"import sys; sys_path = sys.path\")" ]
1,170
1,194
def test_project_path(main_window, tmpdir, qtbot): """Test project path added to spyder_pythonpath and IPython Console.""" projects = main_window.projects # Create a project path path = str(tmpdir.mkdir('project_path')) assert path not in projects.get_conf( 'spyder_pythonpath', section='pythonpath_manager') # Ensure project path is added to spyder_pythonpath projects.open_project(path=path) assert path in projects.get_conf( 'spyder_pythonpath', section='pythonpath_manager') # Ensure project path is added to IPython console shell = main_window.ipyconsole.get_current_shellwidget() qtbot.waitUntil( lambda: shell.spyder_kernel_ready and shell._prompt_html is not None, timeout=SHELL_TIMEOUT) with qtbot.waitSignal(shell.executed): shell.execute("import sys; import os; " "sys_path = sys.path; " "os_path = os.environ.get('PYTHONPATH', [])") assert path in shell.get_value("sys_path") assert path in shell.get_value("os_path") projects.close_project() # Ensure that project path is removed from spyder_pythonpath assert path not in projects.get_conf( 'spyder_pythonpath', section='pythonpath_manager')
test_mainwindow.py
spyder.spyder.app.tests
false
true
[ "import gc", "import os", "import os.path as osp", "from pathlib import Path", "import random", "import re", "import shutil", "import sys", "import tempfile", "from textwrap import dedent", "import time", "from unittest.mock import Mock", "import uuid", "from flaky import flaky", "import ipykernel", "from IPython.core import release as ipy_release", "from matplotlib.testing.compare import compare_images", "import nbconvert", "import numpy as np", "from numpy.testing import assert_array_equal", "from packaging.version import parse", "import pylint", "import pytest", "from qtpy import PYQT_VERSION, PYQT5", "from qtpy.QtCore import QPoint, Qt, QTimer", "from qtpy.QtGui import QImage, QTextCursor", "from qtpy.QtWidgets import QAction, QApplication, QInputDialog, QWidget", "from qtpy.QtWebEngineWidgets import WEBENGINE", "from spyder import __trouble_url__", "from spyder.api.utils import get_class_values", "from spyder.api.widgets.auxiliary_widgets import SpyderWindowWidget", "from spyder.api.plugins import Plugins", "from spyder.app.tests.conftest import (", "from spyder.config.base import (", "from spyder.config.manager import CONF", "from spyder.dependencies import DEPENDENCIES", "from spyder.plugins.debugger.api import DebuggerWidgetActions", "from spyder.plugins.externalterminal.api import ExtTerminalShConfiguration", "from spyder.plugins.help.widgets import ObjectComboBox", "from spyder.plugins.help.tests.test_plugin import check_text", "from spyder.plugins.ipythonconsole.utils.kernel_handler import KernelHandler", "from spyder.plugins.ipythonconsole.api import (", "from spyder.plugins.mainmenu.api import ApplicationMenus", "from spyder.plugins.layout.layouts import DefaultLayouts", "from spyder.plugins.toolbar.api import ApplicationToolbars", "from spyder.plugins.run.api import (", "from spyder.py3compat import qbytearray_to_str, to_text_string", "from spyder.utils.environ import set_user_env", "from spyder.utils.misc import remove_backslashes, rename_file", "from spyder.utils.clipboard_helper import CLIPBOARD_HELPER", "from spyder.utils.programs import find_program", "from spyder.widgets.dock import DockTitleBar", "\"import sys\\n\"", "\"from spyder.utils.external import lockfile\\n\"", "shell.execute('import numpy as np; A=np.full(16, np.nan)')", "shell.execute('import numpy as np')", "(\"import numpy as np\", \"An array object of arbitrary homogeneous items\")])", "shell.execute('import os; current_dir = os.getcwd()')", "shell.execute('import os; current_dir = os.getcwd()')", "shell.execute(\"import sys; import os; \"", "shell.execute(\"import sys; import os; \"", "qtbot.keyClicks(control, 'import os; os.getcwd()')", "shell.execute((\"import matplotlib.pyplot as plt\\n\"", "shell.execute((\"import matplotlib.pyplot as plt\\n\"", "\"import time\\n\"", "shell.execute((\"import matplotlib.pyplot as plt\\n\"", "shell.execute((\"import matplotlib.pyplot as plt\\n\"", "from spyder.widgets.collectionseditor import CollectionsEditor", "from spyder.plugins.pylint.main_widget import PylintWidgetActions", "shell.execute('def foo(): import foo')", "code = (\"import time\\n\"", "from qtpy.QtCore import Qt", "code_def = \"import qtpy.QtCore\"", "shell.execute(\"import time\\n\"", "code = (\"import time\\n\"", "cmd = 'import sys;print(sys.path)'", "code2 = (\"from tmp import a\\n\"", "code2 = (\"from tmp import a\\n\"", "'import time\\n'", "'import time\\n'", "'from file1 import f\\n'", "text = (\"import multiprocessing\\n\"", "\"import traceback\\n\"", "text = (\"import multiprocessing\\n\"", "\"import traceback\\n\"", "import multiprocessing", "import sys", "import ctypes; ctypes.string_at(0)", "\"import threading\\n\"", "'import threading\\n'", "import pprint", "shell.execute(\"import ctypes; ctypes.string_at(0)\")", "shell.execute('import time')", "shell.execute('import time')", "shell.execute(\"import sys; sys_path = sys.path\")", "shell1.execute(\"import sys; sys_path = sys.path\")", "s.execute(\"import sys; sys_path = sys.path\")" ]
1,198
1,229
projects.close_project() # Ensure that project path is removed from spyder_pythonpath assert path not in projects.get_conf( 'spyder_pythonpath', section='pythonpath_manager') # Ensure that project path is removed from IPython console shell = main_window.ipyconsole.get_current_shellwidget() qtbot.waitUntil( lambda: shell.spyder_kernel_ready and shell._prompt_html is not None, timeout=SHELL_TIMEOUT) with qtbot.waitSignal(shell.executed): shell.execute("import sys; import os; " "sys_path = sys.path; " "os_path = os.environ.get('PYTHONPATH', [])") assert path not in shell.get_value("sys_path") assert path not in shell.get_value("os_path")
test_mainwindow.py
spyder.spyder.app.tests
false
false
[ "import gc", "import os", "import os.path as osp", "from pathlib import Path", "import random", "import re", "import shutil", "import sys", "import tempfile", "from textwrap import dedent", "import time", "from unittest.mock import Mock", "import uuid", "from flaky import flaky", "import ipykernel", "from IPython.core import release as ipy_release", "from matplotlib.testing.compare import compare_images", "import nbconvert", "import numpy as np", "from numpy.testing import assert_array_equal", "from packaging.version import parse", "import pylint", "import pytest", "from qtpy import PYQT_VERSION, PYQT5", "from qtpy.QtCore import QPoint, Qt, QTimer", "from qtpy.QtGui import QImage, QTextCursor", "from qtpy.QtWidgets import QAction, QApplication, QInputDialog, QWidget", "from qtpy.QtWebEngineWidgets import WEBENGINE", "from spyder import __trouble_url__", "from spyder.api.utils import get_class_values", "from spyder.api.widgets.auxiliary_widgets import SpyderWindowWidget", "from spyder.api.plugins import Plugins", "from spyder.app.tests.conftest import (", "from spyder.config.base import (", "from spyder.config.manager import CONF", "from spyder.dependencies import DEPENDENCIES", "from spyder.plugins.debugger.api import DebuggerWidgetActions", "from spyder.plugins.externalterminal.api import ExtTerminalShConfiguration", "from spyder.plugins.help.widgets import ObjectComboBox", "from spyder.plugins.help.tests.test_plugin import check_text", "from spyder.plugins.ipythonconsole.utils.kernel_handler import KernelHandler", "from spyder.plugins.ipythonconsole.api import (", "from spyder.plugins.mainmenu.api import ApplicationMenus", "from spyder.plugins.layout.layouts import DefaultLayouts", "from spyder.plugins.toolbar.api import ApplicationToolbars", "from spyder.plugins.run.api import (", "from spyder.py3compat import qbytearray_to_str, to_text_string", "from spyder.utils.environ import set_user_env", "from spyder.utils.misc import remove_backslashes, rename_file", "from spyder.utils.clipboard_helper import CLIPBOARD_HELPER", "from spyder.utils.programs import find_program", "from spyder.widgets.dock import DockTitleBar", "\"import sys\\n\"", "\"from spyder.utils.external import lockfile\\n\"", "shell.execute('import numpy as np; A=np.full(16, np.nan)')", "shell.execute('import numpy as np')", "(\"import numpy as np\", \"An array object of arbitrary homogeneous items\")])", "shell.execute('import os; current_dir = os.getcwd()')", "shell.execute('import os; current_dir = os.getcwd()')", "shell.execute(\"import sys; import os; \"", "shell.execute(\"import sys; import os; \"", "qtbot.keyClicks(control, 'import os; os.getcwd()')", "shell.execute((\"import matplotlib.pyplot as plt\\n\"", "shell.execute((\"import matplotlib.pyplot as plt\\n\"", "\"import time\\n\"", "shell.execute((\"import matplotlib.pyplot as plt\\n\"", "shell.execute((\"import matplotlib.pyplot as plt\\n\"", "from spyder.widgets.collectionseditor import CollectionsEditor", "from spyder.plugins.pylint.main_widget import PylintWidgetActions", "shell.execute('def foo(): import foo')", "code = (\"import time\\n\"", "from qtpy.QtCore import Qt", "code_def = \"import qtpy.QtCore\"", "shell.execute(\"import time\\n\"", "code = (\"import time\\n\"", "cmd = 'import sys;print(sys.path)'", "code2 = (\"from tmp import a\\n\"", "code2 = (\"from tmp import a\\n\"", "'import time\\n'", "'import time\\n'", "'from file1 import f\\n'", "text = (\"import multiprocessing\\n\"", "\"import traceback\\n\"", "text = (\"import multiprocessing\\n\"", "\"import traceback\\n\"", "import multiprocessing", "import sys", "import ctypes; ctypes.string_at(0)", "\"import threading\\n\"", "'import threading\\n'", "import pprint", "shell.execute(\"import ctypes; ctypes.string_at(0)\")", "shell.execute('import time')", "shell.execute('import time')", "shell.execute(\"import sys; sys_path = sys.path\")", "shell1.execute(\"import sys; sys_path = sys.path\")", "s.execute(\"import sys; sys_path = sys.path\")" ]
599
616
def test_open_notebooks_from_project_explorer(main_window, qtbot, tmpdir): """Test that notebooks are open from the Project explorer.""" # Wait until the window is fully up shell = main_window.ipyconsole.get_current_shellwidget() qtbot.waitUntil( lambda: shell.spyder_kernel_ready and shell._prompt_html is not None, timeout=SHELL_TIMEOUT) projects = main_window.projects projects.toggle_view_action.setChecked(True) editorstack = main_window.editor.get_current_editorstack() # Create a temp project directory project_dir = to_text_string(tmpdir.mkdir('test')) # Create an empty notebook in the project dir nb = osp.join(LOCATION, 'notebook.ipynb') shutil.copy(nb, osp.join(project_dir, 'notebook.ipynb')) # Create project with qtbot.waitSignal(projects.sig_project_loaded): projects.create_project(project_dir) # Select notebook in the project explorer idx = projects.get_widget().treewidget.get_index( osp.join(project_dir, 'notebook.ipynb')) projects.get_widget().treewidget.setCurrentIndex(idx) # Prese Enter there qtbot.keyClick(projects.get_widget().treewidget, Qt.Key_Enter) # Assert that notebook was open assert 'notebook.ipynb' in editorstack.get_current_filename() # Convert notebook to a Python file projects.get_widget().treewidget.convert_notebook( osp.join(project_dir, 'notebook.ipynb'))
test_mainwindow.py
spyder.spyder.app.tests
false
true
[ "import gc", "import os", "import os.path as osp", "from pathlib import Path", "import random", "import re", "import shutil", "import sys", "import tempfile", "from textwrap import dedent", "import time", "from unittest.mock import Mock", "import uuid", "from flaky import flaky", "import ipykernel", "from IPython.core import release as ipy_release", "from matplotlib.testing.compare import compare_images", "import nbconvert", "import numpy as np", "from numpy.testing import assert_array_equal", "from packaging.version import parse", "import pylint", "import pytest", "from qtpy import PYQT_VERSION, PYQT5", "from qtpy.QtCore import QPoint, Qt, QTimer", "from qtpy.QtGui import QImage, QTextCursor", "from qtpy.QtWidgets import QAction, QApplication, QInputDialog, QWidget", "from qtpy.QtWebEngineWidgets import WEBENGINE", "from spyder import __trouble_url__", "from spyder.api.utils import get_class_values", "from spyder.api.widgets.auxiliary_widgets import SpyderWindowWidget", "from spyder.api.plugins import Plugins", "from spyder.app.tests.conftest import (", "from spyder.config.base import (", "from spyder.config.manager import CONF", "from spyder.dependencies import DEPENDENCIES", "from spyder.plugins.debugger.api import DebuggerWidgetActions", "from spyder.plugins.externalterminal.api import ExtTerminalShConfiguration", "from spyder.plugins.help.widgets import ObjectComboBox", "from spyder.plugins.help.tests.test_plugin import check_text", "from spyder.plugins.ipythonconsole.utils.kernel_handler import KernelHandler", "from spyder.plugins.ipythonconsole.api import (", "from spyder.plugins.mainmenu.api import ApplicationMenus", "from spyder.plugins.layout.layouts import DefaultLayouts", "from spyder.plugins.toolbar.api import ApplicationToolbars", "from spyder.plugins.run.api import (", "from spyder.py3compat import qbytearray_to_str, to_text_string", "from spyder.utils.environ import set_user_env", "from spyder.utils.misc import remove_backslashes, rename_file", "from spyder.utils.clipboard_helper import CLIPBOARD_HELPER", "from spyder.utils.programs import find_program", "from spyder.widgets.dock import DockTitleBar", "\"import sys\\n\"", "\"from spyder.utils.external import lockfile\\n\"", "shell.execute('import numpy as np; A=np.full(16, np.nan)')", "shell.execute('import numpy as np')", "(\"import numpy as np\", \"An array object of arbitrary homogeneous items\")])", "shell.execute('import os; current_dir = os.getcwd()')", "shell.execute('import os; current_dir = os.getcwd()')", "shell.execute(\"import sys; import os; \"", "shell.execute(\"import sys; import os; \"", "qtbot.keyClicks(control, 'import os; os.getcwd()')", "shell.execute((\"import matplotlib.pyplot as plt\\n\"", "shell.execute((\"import matplotlib.pyplot as plt\\n\"", "\"import time\\n\"", "shell.execute((\"import matplotlib.pyplot as plt\\n\"", "shell.execute((\"import matplotlib.pyplot as plt\\n\"", "from spyder.widgets.collectionseditor import CollectionsEditor", "from spyder.plugins.pylint.main_widget import PylintWidgetActions", "shell.execute('def foo(): import foo')", "code = (\"import time\\n\"", "from qtpy.QtCore import Qt", "code_def = \"import qtpy.QtCore\"", "shell.execute(\"import time\\n\"", "code = (\"import time\\n\"", "cmd = 'import sys;print(sys.path)'", "code2 = (\"from tmp import a\\n\"", "code2 = (\"from tmp import a\\n\"", "'import time\\n'", "'import time\\n'", "'from file1 import f\\n'", "text = (\"import multiprocessing\\n\"", "\"import traceback\\n\"", "text = (\"import multiprocessing\\n\"", "\"import traceback\\n\"", "import multiprocessing", "import sys", "import ctypes; ctypes.string_at(0)", "\"import threading\\n\"", "'import threading\\n'", "import pprint", "shell.execute(\"import ctypes; ctypes.string_at(0)\")", "shell.execute('import time')", "shell.execute('import time')", "shell.execute(\"import sys; sys_path = sys.path\")", "shell1.execute(\"import sys; sys_path = sys.path\")", "s.execute(\"import sys; sys_path = sys.path\")" ]
1,247
1,283
# Convert notebook to a Python file projects.get_widget().treewidget.convert_notebook( osp.join(project_dir, 'notebook.ipynb')) # Assert notebook was open assert 'untitled' in editorstack.get_current_filename() # Assert its contents are the expected ones file_text = editorstack.get_current_editor().toPlainText() if nbconvert.__version__ >= '5.4.0': expected_text = ('#!/usr/bin/env python\n# coding: utf-8\n\n# In[1]:' '\n\n\n1 + 1\n\n\n# In[ ]:\n\n\n\n\n') else: expected_text = '\n# coding: utf-8\n\n# In[1]:\n\n\n1 + 1\n\n\n' assert file_text == expected_text # Close project projects.close_project()
test_mainwindow.py
spyder.spyder.app.tests
false
false
[ "import gc", "import os", "import os.path as osp", "from pathlib import Path", "import random", "import re", "import shutil", "import sys", "import tempfile", "from textwrap import dedent", "import time", "from unittest.mock import Mock", "import uuid", "from flaky import flaky", "import ipykernel", "from IPython.core import release as ipy_release", "from matplotlib.testing.compare import compare_images", "import nbconvert", "import numpy as np", "from numpy.testing import assert_array_equal", "from packaging.version import parse", "import pylint", "import pytest", "from qtpy import PYQT_VERSION, PYQT5", "from qtpy.QtCore import QPoint, Qt, QTimer", "from qtpy.QtGui import QImage, QTextCursor", "from qtpy.QtWidgets import QAction, QApplication, QInputDialog, QWidget", "from qtpy.QtWebEngineWidgets import WEBENGINE", "from spyder import __trouble_url__", "from spyder.api.utils import get_class_values", "from spyder.api.widgets.auxiliary_widgets import SpyderWindowWidget", "from spyder.api.plugins import Plugins", "from spyder.app.tests.conftest import (", "from spyder.config.base import (", "from spyder.config.manager import CONF", "from spyder.dependencies import DEPENDENCIES", "from spyder.plugins.debugger.api import DebuggerWidgetActions", "from spyder.plugins.externalterminal.api import ExtTerminalShConfiguration", "from spyder.plugins.help.widgets import ObjectComboBox", "from spyder.plugins.help.tests.test_plugin import check_text", "from spyder.plugins.ipythonconsole.utils.kernel_handler import KernelHandler", "from spyder.plugins.ipythonconsole.api import (", "from spyder.plugins.mainmenu.api import ApplicationMenus", "from spyder.plugins.layout.layouts import DefaultLayouts", "from spyder.plugins.toolbar.api import ApplicationToolbars", "from spyder.plugins.run.api import (", "from spyder.py3compat import qbytearray_to_str, to_text_string", "from spyder.utils.environ import set_user_env", "from spyder.utils.misc import remove_backslashes, rename_file", "from spyder.utils.clipboard_helper import CLIPBOARD_HELPER", "from spyder.utils.programs import find_program", "from spyder.widgets.dock import DockTitleBar", "\"import sys\\n\"", "\"from spyder.utils.external import lockfile\\n\"", "shell.execute('import numpy as np; A=np.full(16, np.nan)')", "shell.execute('import numpy as np')", "(\"import numpy as np\", \"An array object of arbitrary homogeneous items\")])", "shell.execute('import os; current_dir = os.getcwd()')", "shell.execute('import os; current_dir = os.getcwd()')", "shell.execute(\"import sys; import os; \"", "shell.execute(\"import sys; import os; \"", "qtbot.keyClicks(control, 'import os; os.getcwd()')", "shell.execute((\"import matplotlib.pyplot as plt\\n\"", "shell.execute((\"import matplotlib.pyplot as plt\\n\"", "\"import time\\n\"", "shell.execute((\"import matplotlib.pyplot as plt\\n\"", "shell.execute((\"import matplotlib.pyplot as plt\\n\"", "from spyder.widgets.collectionseditor import CollectionsEditor", "from spyder.plugins.pylint.main_widget import PylintWidgetActions", "shell.execute('def foo(): import foo')", "code = (\"import time\\n\"", "from qtpy.QtCore import Qt", "code_def = \"import qtpy.QtCore\"", "shell.execute(\"import time\\n\"", "code = (\"import time\\n\"", "cmd = 'import sys;print(sys.path)'", "code2 = (\"from tmp import a\\n\"", "code2 = (\"from tmp import a\\n\"", "'import time\\n'", "'import time\\n'", "'from file1 import f\\n'", "text = (\"import multiprocessing\\n\"", "\"import traceback\\n\"", "text = (\"import multiprocessing\\n\"", "\"import traceback\\n\"", "import multiprocessing", "import sys", "import ctypes; ctypes.string_at(0)", "\"import threading\\n\"", "'import threading\\n'", "import pprint", "shell.execute(\"import ctypes; ctypes.string_at(0)\")", "shell.execute('import time')", "shell.execute('import time')", "shell.execute(\"import sys; sys_path = sys.path\")", "shell1.execute(\"import sys; sys_path = sys.path\")", "s.execute(\"import sys; sys_path = sys.path\")" ]
1,281
1,298
def test_runfile_from_project_explorer(main_window, qtbot, tmpdir): """Test that file are run from the Project explorer.""" # Wait until the window is fully up shell = main_window.ipyconsole.get_current_shellwidget() qtbot.waitUntil( lambda: shell.spyder_kernel_ready and shell._prompt_html is not None, timeout=SHELL_TIMEOUT) projects = main_window.projects projects.toggle_view_action.setChecked(True) editorstack = main_window.editor.get_current_editorstack() # Create a temp project directory project_dir = to_text_string(tmpdir.mkdir('test')) # Create an empty file in the project dir test_file = osp.join(LOCATION, 'script.py') shutil.copy(test_file, osp.join(project_dir, 'script.py')) # Create project with qtbot.waitSignal(projects.sig_project_loaded): projects.create_project(project_dir) # Select file in the project explorer idx = projects.get_widget().treewidget.get_index( osp.join(project_dir, 'script.py')) projects.get_widget().treewidget.setCurrentIndex(idx) # Press Enter there qtbot.keyClick(projects.get_widget().treewidget, Qt.Key_Enter) # Assert that the file was open assert 'script.py' in editorstack.get_current_filename() # Run Python file projects.get_widget().treewidget.run([osp.join(project_dir, 'script.py')])
test_mainwindow.py
spyder.spyder.app.tests
false
true
[ "import gc", "import os", "import os.path as osp", "from pathlib import Path", "import random", "import re", "import shutil", "import sys", "import tempfile", "from textwrap import dedent", "import time", "from unittest.mock import Mock", "import uuid", "from flaky import flaky", "import ipykernel", "from IPython.core import release as ipy_release", "from matplotlib.testing.compare import compare_images", "import nbconvert", "import numpy as np", "from numpy.testing import assert_array_equal", "from packaging.version import parse", "import pylint", "import pytest", "from qtpy import PYQT_VERSION, PYQT5", "from qtpy.QtCore import QPoint, Qt, QTimer", "from qtpy.QtGui import QImage, QTextCursor", "from qtpy.QtWidgets import QAction, QApplication, QInputDialog, QWidget", "from qtpy.QtWebEngineWidgets import WEBENGINE", "from spyder import __trouble_url__", "from spyder.api.utils import get_class_values", "from spyder.api.widgets.auxiliary_widgets import SpyderWindowWidget", "from spyder.api.plugins import Plugins", "from spyder.app.tests.conftest import (", "from spyder.config.base import (", "from spyder.config.manager import CONF", "from spyder.dependencies import DEPENDENCIES", "from spyder.plugins.debugger.api import DebuggerWidgetActions", "from spyder.plugins.externalterminal.api import ExtTerminalShConfiguration", "from spyder.plugins.help.widgets import ObjectComboBox", "from spyder.plugins.help.tests.test_plugin import check_text", "from spyder.plugins.ipythonconsole.utils.kernel_handler import KernelHandler", "from spyder.plugins.ipythonconsole.api import (", "from spyder.plugins.mainmenu.api import ApplicationMenus", "from spyder.plugins.layout.layouts import DefaultLayouts", "from spyder.plugins.toolbar.api import ApplicationToolbars", "from spyder.plugins.run.api import (", "from spyder.py3compat import qbytearray_to_str, to_text_string", "from spyder.utils.environ import set_user_env", "from spyder.utils.misc import remove_backslashes, rename_file", "from spyder.utils.clipboard_helper import CLIPBOARD_HELPER", "from spyder.utils.programs import find_program", "from spyder.widgets.dock import DockTitleBar", "\"import sys\\n\"", "\"from spyder.utils.external import lockfile\\n\"", "shell.execute('import numpy as np; A=np.full(16, np.nan)')", "shell.execute('import numpy as np')", "(\"import numpy as np\", \"An array object of arbitrary homogeneous items\")])", "shell.execute('import os; current_dir = os.getcwd()')", "shell.execute('import os; current_dir = os.getcwd()')", "shell.execute(\"import sys; import os; \"", "shell.execute(\"import sys; import os; \"", "qtbot.keyClicks(control, 'import os; os.getcwd()')", "shell.execute((\"import matplotlib.pyplot as plt\\n\"", "shell.execute((\"import matplotlib.pyplot as plt\\n\"", "\"import time\\n\"", "shell.execute((\"import matplotlib.pyplot as plt\\n\"", "shell.execute((\"import matplotlib.pyplot as plt\\n\"", "from spyder.widgets.collectionseditor import CollectionsEditor", "from spyder.plugins.pylint.main_widget import PylintWidgetActions", "shell.execute('def foo(): import foo')", "code = (\"import time\\n\"", "from qtpy.QtCore import Qt", "code_def = \"import qtpy.QtCore\"", "shell.execute(\"import time\\n\"", "code = (\"import time\\n\"", "cmd = 'import sys;print(sys.path)'", "code2 = (\"from tmp import a\\n\"", "code2 = (\"from tmp import a\\n\"", "'import time\\n'", "'import time\\n'", "'from file1 import f\\n'", "text = (\"import multiprocessing\\n\"", "\"import traceback\\n\"", "text = (\"import multiprocessing\\n\"", "\"import traceback\\n\"", "import multiprocessing", "import sys", "import ctypes; ctypes.string_at(0)", "\"import threading\\n\"", "'import threading\\n'", "import pprint", "shell.execute(\"import ctypes; ctypes.string_at(0)\")", "shell.execute('import time')", "shell.execute('import time')", "shell.execute(\"import sys; sys_path = sys.path\")", "shell1.execute(\"import sys; sys_path = sys.path\")", "s.execute(\"import sys; sys_path = sys.path\")" ]
1,302
1,337
# Assert that the file was open assert 'script.py' in editorstack.get_current_filename() # Run Python file projects.get_widget().treewidget.run([osp.join(project_dir, 'script.py')]) # Wait until the new console is fully up shell = main_window.ipyconsole.get_current_shellwidget() qtbot.waitUntil( lambda: shell.spyder_kernel_ready and shell._prompt_html is not None, timeout=SHELL_TIMEOUT) # Wait until all objects have appeared in the variable explorer nsb = main_window.variableexplorer.current_widget() qtbot.waitUntil(lambda: nsb.editor.source_model.rowCount() == 4, timeout=EVAL_TIMEOUT) # Check variables value assert shell.get_value('a') == 10 assert shell.get_value('s') == "Z:\\escape\\test\\string\n" assert shell.get_value('li') == [1, 2, 3] assert_array_equal(shell.get_value('arr'), np.array([1, 2, 3])) # Close project projects.close_project()
test_mainwindow.py
spyder.spyder.app.tests
false
false
[ "import gc", "import os", "import os.path as osp", "from pathlib import Path", "import random", "import re", "import shutil", "import sys", "import tempfile", "from textwrap import dedent", "import time", "from unittest.mock import Mock", "import uuid", "from flaky import flaky", "import ipykernel", "from IPython.core import release as ipy_release", "from matplotlib.testing.compare import compare_images", "import nbconvert", "import numpy as np", "from numpy.testing import assert_array_equal", "from packaging.version import parse", "import pylint", "import pytest", "from qtpy import PYQT_VERSION, PYQT5", "from qtpy.QtCore import QPoint, Qt, QTimer", "from qtpy.QtGui import QImage, QTextCursor", "from qtpy.QtWidgets import QAction, QApplication, QInputDialog, QWidget", "from qtpy.QtWebEngineWidgets import WEBENGINE", "from spyder import __trouble_url__", "from spyder.api.utils import get_class_values", "from spyder.api.widgets.auxiliary_widgets import SpyderWindowWidget", "from spyder.api.plugins import Plugins", "from spyder.app.tests.conftest import (", "from spyder.config.base import (", "from spyder.config.manager import CONF", "from spyder.dependencies import DEPENDENCIES", "from spyder.plugins.debugger.api import DebuggerWidgetActions", "from spyder.plugins.externalterminal.api import ExtTerminalShConfiguration", "from spyder.plugins.help.widgets import ObjectComboBox", "from spyder.plugins.help.tests.test_plugin import check_text", "from spyder.plugins.ipythonconsole.utils.kernel_handler import KernelHandler", "from spyder.plugins.ipythonconsole.api import (", "from spyder.plugins.mainmenu.api import ApplicationMenus", "from spyder.plugins.layout.layouts import DefaultLayouts", "from spyder.plugins.toolbar.api import ApplicationToolbars", "from spyder.plugins.run.api import (", "from spyder.py3compat import qbytearray_to_str, to_text_string", "from spyder.utils.environ import set_user_env", "from spyder.utils.misc import remove_backslashes, rename_file", "from spyder.utils.clipboard_helper import CLIPBOARD_HELPER", "from spyder.utils.programs import find_program", "from spyder.widgets.dock import DockTitleBar", "\"import sys\\n\"", "\"from spyder.utils.external import lockfile\\n\"", "shell.execute('import numpy as np; A=np.full(16, np.nan)')", "shell.execute('import numpy as np')", "(\"import numpy as np\", \"An array object of arbitrary homogeneous items\")])", "shell.execute('import os; current_dir = os.getcwd()')", "shell.execute('import os; current_dir = os.getcwd()')", "shell.execute(\"import sys; import os; \"", "shell.execute(\"import sys; import os; \"", "qtbot.keyClicks(control, 'import os; os.getcwd()')", "shell.execute((\"import matplotlib.pyplot as plt\\n\"", "shell.execute((\"import matplotlib.pyplot as plt\\n\"", "\"import time\\n\"", "shell.execute((\"import matplotlib.pyplot as plt\\n\"", "shell.execute((\"import matplotlib.pyplot as plt\\n\"", "from spyder.widgets.collectionseditor import CollectionsEditor", "from spyder.plugins.pylint.main_widget import PylintWidgetActions", "shell.execute('def foo(): import foo')", "code = (\"import time\\n\"", "from qtpy.QtCore import Qt", "code_def = \"import qtpy.QtCore\"", "shell.execute(\"import time\\n\"", "code = (\"import time\\n\"", "cmd = 'import sys;print(sys.path)'", "code2 = (\"from tmp import a\\n\"", "code2 = (\"from tmp import a\\n\"", "'import time\\n'", "'import time\\n'", "'from file1 import f\\n'", "text = (\"import multiprocessing\\n\"", "\"import traceback\\n\"", "text = (\"import multiprocessing\\n\"", "\"import traceback\\n\"", "import multiprocessing", "import sys", "import ctypes; ctypes.string_at(0)", "\"import threading\\n\"", "'import threading\\n'", "import pprint", "shell.execute(\"import ctypes; ctypes.string_at(0)\")", "shell.execute('import time')", "shell.execute('import time')", "shell.execute(\"import sys; sys_path = sys.path\")", "shell1.execute(\"import sys; sys_path = sys.path\")", "s.execute(\"import sys; sys_path = sys.path\")" ]
1,333
1,357
def test_set_new_breakpoints(main_window, qtbot): """Test that new breakpoints are set in the IPython console.""" # Wait until the window is fully up shell = main_window.ipyconsole.get_current_shellwidget() control = shell._control qtbot.waitUntil( lambda: shell.spyder_kernel_ready and shell._prompt_html is not None, timeout=SHELL_TIMEOUT) # Clear all breakpoints main_window.debugger.clear_all_breakpoints() # Load test file test_file = osp.join(LOCATION, 'script.py') main_window.editor.load(test_file) # Click the debug button debug_button = main_window.debug_button with qtbot.waitSignal(shell.executed): qtbot.mouseClick(debug_button, Qt.LeftButton) # Set a breakpoint code_editor = main_window.editor.get_focus_widget() code_editor.breakpoints_manager.toogle_breakpoint(line_number=6) # Verify that the breakpoint was set with qtbot.waitSignal(shell.executed): shell.pdb_execute("!b") assert "1 breakpoint keep yes at {}:6".format( test_file) in control.toPlainText() # Remove breakpoint and close test file main_window.debugger.clear_all_breakpoints() main_window.editor.close_file()
test_mainwindow.py
spyder.spyder.app.tests
false
true
[ "import gc", "import os", "import os.path as osp", "from pathlib import Path", "import random", "import re", "import shutil", "import sys", "import tempfile", "from textwrap import dedent", "import time", "from unittest.mock import Mock", "import uuid", "from flaky import flaky", "import ipykernel", "from IPython.core import release as ipy_release", "from matplotlib.testing.compare import compare_images", "import nbconvert", "import numpy as np", "from numpy.testing import assert_array_equal", "from packaging.version import parse", "import pylint", "import pytest", "from qtpy import PYQT_VERSION, PYQT5", "from qtpy.QtCore import QPoint, Qt, QTimer", "from qtpy.QtGui import QImage, QTextCursor", "from qtpy.QtWidgets import QAction, QApplication, QInputDialog, QWidget", "from qtpy.QtWebEngineWidgets import WEBENGINE", "from spyder import __trouble_url__", "from spyder.api.utils import get_class_values", "from spyder.api.widgets.auxiliary_widgets import SpyderWindowWidget", "from spyder.api.plugins import Plugins", "from spyder.app.tests.conftest import (", "from spyder.config.base import (", "from spyder.config.manager import CONF", "from spyder.dependencies import DEPENDENCIES", "from spyder.plugins.debugger.api import DebuggerWidgetActions", "from spyder.plugins.externalterminal.api import ExtTerminalShConfiguration", "from spyder.plugins.help.widgets import ObjectComboBox", "from spyder.plugins.help.tests.test_plugin import check_text", "from spyder.plugins.ipythonconsole.utils.kernel_handler import KernelHandler", "from spyder.plugins.ipythonconsole.api import (", "from spyder.plugins.mainmenu.api import ApplicationMenus", "from spyder.plugins.layout.layouts import DefaultLayouts", "from spyder.plugins.toolbar.api import ApplicationToolbars", "from spyder.plugins.run.api import (", "from spyder.py3compat import qbytearray_to_str, to_text_string", "from spyder.utils.environ import set_user_env", "from spyder.utils.misc import remove_backslashes, rename_file", "from spyder.utils.clipboard_helper import CLIPBOARD_HELPER", "from spyder.utils.programs import find_program", "from spyder.widgets.dock import DockTitleBar", "\"import sys\\n\"", "\"from spyder.utils.external import lockfile\\n\"", "shell.execute('import numpy as np; A=np.full(16, np.nan)')", "shell.execute('import numpy as np')", "(\"import numpy as np\", \"An array object of arbitrary homogeneous items\")])", "shell.execute('import os; current_dir = os.getcwd()')", "shell.execute('import os; current_dir = os.getcwd()')", "shell.execute(\"import sys; import os; \"", "shell.execute(\"import sys; import os; \"", "qtbot.keyClicks(control, 'import os; os.getcwd()')", "shell.execute((\"import matplotlib.pyplot as plt\\n\"", "shell.execute((\"import matplotlib.pyplot as plt\\n\"", "\"import time\\n\"", "shell.execute((\"import matplotlib.pyplot as plt\\n\"", "shell.execute((\"import matplotlib.pyplot as plt\\n\"", "from spyder.widgets.collectionseditor import CollectionsEditor", "from spyder.plugins.pylint.main_widget import PylintWidgetActions", "shell.execute('def foo(): import foo')", "code = (\"import time\\n\"", "from qtpy.QtCore import Qt", "code_def = \"import qtpy.QtCore\"", "shell.execute(\"import time\\n\"", "code = (\"import time\\n\"", "cmd = 'import sys;print(sys.path)'", "code2 = (\"from tmp import a\\n\"", "code2 = (\"from tmp import a\\n\"", "'import time\\n'", "'import time\\n'", "'from file1 import f\\n'", "text = (\"import multiprocessing\\n\"", "\"import traceback\\n\"", "text = (\"import multiprocessing\\n\"", "\"import traceback\\n\"", "import multiprocessing", "import sys", "import ctypes; ctypes.string_at(0)", "\"import threading\\n\"", "'import threading\\n'", "import pprint", "shell.execute(\"import ctypes; ctypes.string_at(0)\")", "shell.execute('import time')", "shell.execute('import time')", "shell.execute(\"import sys; sys_path = sys.path\")", "shell1.execute(\"import sys; sys_path = sys.path\")", "s.execute(\"import sys; sys_path = sys.path\")" ]
1,363
1,396
def test_run_code(main_window, qtbot, tmpdir): """Test all the different ways we have to run code""" # ---- Setup ---- p = (tmpdir.mkdir(u"runtest's folder èáïü Øαôå 字分误") .join(u"runtest's file èáïü Øαôå 字分误.py")) filepath = to_text_string(p) shutil.copyfile(osp.join(LOCATION, 'script.py'), filepath) # Wait until the window is fully up shell = main_window.ipyconsole.get_current_shellwidget() qtbot.waitUntil( lambda: shell.spyder_kernel_ready and shell._prompt_html is not None, timeout=SHELL_TIMEOUT) # Load test file main_window.editor.load(filepath) # Move to the editor's first line editor = main_window.editor code_editor = editor.get_focus_widget() code_editor.setFocus() qtbot.keyClick(code_editor, Qt.Key_Home, modifier=Qt.ControlModifier) # Get a reference to the namespace browser widget nsb = main_window.variableexplorer.current_widget() run_parameters = generate_run_parameters(main_window, filepath) CONF.set('run', 'last_used_parameters', run_parameters) # ---- Run file ---- with qtbot.waitSignal(shell.executed): qtbot.keyClick(code_editor, Qt.Key_F5) # Wait until all objects have appeared in the variable explorer qtbot.waitUntil(lambda: nsb.editor.source_model.rowCount() == 4, timeout=EVAL_TIMEOUT)
test_mainwindow.py
spyder.spyder.app.tests
false
true
[ "import gc", "import os", "import os.path as osp", "from pathlib import Path", "import random", "import re", "import shutil", "import sys", "import tempfile", "from textwrap import dedent", "import time", "from unittest.mock import Mock", "import uuid", "from flaky import flaky", "import ipykernel", "from IPython.core import release as ipy_release", "from matplotlib.testing.compare import compare_images", "import nbconvert", "import numpy as np", "from numpy.testing import assert_array_equal", "from packaging.version import parse", "import pylint", "import pytest", "from qtpy import PYQT_VERSION, PYQT5", "from qtpy.QtCore import QPoint, Qt, QTimer", "from qtpy.QtGui import QImage, QTextCursor", "from qtpy.QtWidgets import QAction, QApplication, QInputDialog, QWidget", "from qtpy.QtWebEngineWidgets import WEBENGINE", "from spyder import __trouble_url__", "from spyder.api.utils import get_class_values", "from spyder.api.widgets.auxiliary_widgets import SpyderWindowWidget", "from spyder.api.plugins import Plugins", "from spyder.app.tests.conftest import (", "from spyder.config.base import (", "from spyder.config.manager import CONF", "from spyder.dependencies import DEPENDENCIES", "from spyder.plugins.debugger.api import DebuggerWidgetActions", "from spyder.plugins.externalterminal.api import ExtTerminalShConfiguration", "from spyder.plugins.help.widgets import ObjectComboBox", "from spyder.plugins.help.tests.test_plugin import check_text", "from spyder.plugins.ipythonconsole.utils.kernel_handler import KernelHandler", "from spyder.plugins.ipythonconsole.api import (", "from spyder.plugins.mainmenu.api import ApplicationMenus", "from spyder.plugins.layout.layouts import DefaultLayouts", "from spyder.plugins.toolbar.api import ApplicationToolbars", "from spyder.plugins.run.api import (", "from spyder.py3compat import qbytearray_to_str, to_text_string", "from spyder.utils.environ import set_user_env", "from spyder.utils.misc import remove_backslashes, rename_file", "from spyder.utils.clipboard_helper import CLIPBOARD_HELPER", "from spyder.utils.programs import find_program", "from spyder.widgets.dock import DockTitleBar", "\"import sys\\n\"", "\"from spyder.utils.external import lockfile\\n\"", "shell.execute('import numpy as np; A=np.full(16, np.nan)')", "shell.execute('import numpy as np')", "(\"import numpy as np\", \"An array object of arbitrary homogeneous items\")])", "shell.execute('import os; current_dir = os.getcwd()')", "shell.execute('import os; current_dir = os.getcwd()')", "shell.execute(\"import sys; import os; \"", "shell.execute(\"import sys; import os; \"", "qtbot.keyClicks(control, 'import os; os.getcwd()')", "shell.execute((\"import matplotlib.pyplot as plt\\n\"", "shell.execute((\"import matplotlib.pyplot as plt\\n\"", "\"import time\\n\"", "shell.execute((\"import matplotlib.pyplot as plt\\n\"", "shell.execute((\"import matplotlib.pyplot as plt\\n\"", "from spyder.widgets.collectionseditor import CollectionsEditor", "from spyder.plugins.pylint.main_widget import PylintWidgetActions", "shell.execute('def foo(): import foo')", "code = (\"import time\\n\"", "from qtpy.QtCore import Qt", "code_def = \"import qtpy.QtCore\"", "shell.execute(\"import time\\n\"", "code = (\"import time\\n\"", "cmd = 'import sys;print(sys.path)'", "code2 = (\"from tmp import a\\n\"", "code2 = (\"from tmp import a\\n\"", "'import time\\n'", "'import time\\n'", "'from file1 import f\\n'", "text = (\"import multiprocessing\\n\"", "\"import traceback\\n\"", "text = (\"import multiprocessing\\n\"", "\"import traceback\\n\"", "import multiprocessing", "import sys", "import ctypes; ctypes.string_at(0)", "\"import threading\\n\"", "'import threading\\n'", "import pprint", "shell.execute(\"import ctypes; ctypes.string_at(0)\")", "shell.execute('import time')", "shell.execute('import time')", "shell.execute(\"import sys; sys_path = sys.path\")", "shell1.execute(\"import sys; sys_path = sys.path\")", "s.execute(\"import sys; sys_path = sys.path\")" ]
1,401
1,436
# Wait until all objects have appeared in the variable explorer qtbot.waitUntil(lambda: nsb.editor.source_model.rowCount() == 4, timeout=EVAL_TIMEOUT) # Verify result assert shell.get_value('a') == 10 assert shell.get_value('s') == "Z:\\escape\\test\\string\n" assert shell.get_value('li') == [1, 2, 3] assert_array_equal(shell.get_value('arr'), np.array([1, 2, 3])) reset_run_code(qtbot, shell, code_editor, nsb) # ---- Run lines ---- # Run the whole file line by line for _ in range(code_editor.blockCount()): with qtbot.waitSignal(shell.executed): qtbot.mouseClick(main_window.run_selection_button, Qt.LeftButton) qtbot.wait(200) # Wait until all objects have appeared in the variable explorer qtbot.waitUntil(lambda: nsb.editor.source_model.rowCount() == 4, timeout=EVAL_TIMEOUT) # Verify result assert shell.get_value('a') == 10 assert shell.get_value('s') == "Z:\\escape\\test\\string\n" assert shell.get_value('li') == [1, 2, 3] assert_array_equal(shell.get_value('arr'), np.array([1, 2, 3])) reset_run_code(qtbot, shell, code_editor, nsb)
test_mainwindow.py
spyder.spyder.app.tests
false
false
[ "import gc", "import os", "import os.path as osp", "from pathlib import Path", "import random", "import re", "import shutil", "import sys", "import tempfile", "from textwrap import dedent", "import time", "from unittest.mock import Mock", "import uuid", "from flaky import flaky", "import ipykernel", "from IPython.core import release as ipy_release", "from matplotlib.testing.compare import compare_images", "import nbconvert", "import numpy as np", "from numpy.testing import assert_array_equal", "from packaging.version import parse", "import pylint", "import pytest", "from qtpy import PYQT_VERSION, PYQT5", "from qtpy.QtCore import QPoint, Qt, QTimer", "from qtpy.QtGui import QImage, QTextCursor", "from qtpy.QtWidgets import QAction, QApplication, QInputDialog, QWidget", "from qtpy.QtWebEngineWidgets import WEBENGINE", "from spyder import __trouble_url__", "from spyder.api.utils import get_class_values", "from spyder.api.widgets.auxiliary_widgets import SpyderWindowWidget", "from spyder.api.plugins import Plugins", "from spyder.app.tests.conftest import (", "from spyder.config.base import (", "from spyder.config.manager import CONF", "from spyder.dependencies import DEPENDENCIES", "from spyder.plugins.debugger.api import DebuggerWidgetActions", "from spyder.plugins.externalterminal.api import ExtTerminalShConfiguration", "from spyder.plugins.help.widgets import ObjectComboBox", "from spyder.plugins.help.tests.test_plugin import check_text", "from spyder.plugins.ipythonconsole.utils.kernel_handler import KernelHandler", "from spyder.plugins.ipythonconsole.api import (", "from spyder.plugins.mainmenu.api import ApplicationMenus", "from spyder.plugins.layout.layouts import DefaultLayouts", "from spyder.plugins.toolbar.api import ApplicationToolbars", "from spyder.plugins.run.api import (", "from spyder.py3compat import qbytearray_to_str, to_text_string", "from spyder.utils.environ import set_user_env", "from spyder.utils.misc import remove_backslashes, rename_file", "from spyder.utils.clipboard_helper import CLIPBOARD_HELPER", "from spyder.utils.programs import find_program", "from spyder.widgets.dock import DockTitleBar", "\"import sys\\n\"", "\"from spyder.utils.external import lockfile\\n\"", "shell.execute('import numpy as np; A=np.full(16, np.nan)')", "shell.execute('import numpy as np')", "(\"import numpy as np\", \"An array object of arbitrary homogeneous items\")])", "shell.execute('import os; current_dir = os.getcwd()')", "shell.execute('import os; current_dir = os.getcwd()')", "shell.execute(\"import sys; import os; \"", "shell.execute(\"import sys; import os; \"", "qtbot.keyClicks(control, 'import os; os.getcwd()')", "shell.execute((\"import matplotlib.pyplot as plt\\n\"", "shell.execute((\"import matplotlib.pyplot as plt\\n\"", "\"import time\\n\"", "shell.execute((\"import matplotlib.pyplot as plt\\n\"", "shell.execute((\"import matplotlib.pyplot as plt\\n\"", "from spyder.widgets.collectionseditor import CollectionsEditor", "from spyder.plugins.pylint.main_widget import PylintWidgetActions", "shell.execute('def foo(): import foo')", "code = (\"import time\\n\"", "from qtpy.QtCore import Qt", "code_def = \"import qtpy.QtCore\"", "shell.execute(\"import time\\n\"", "code = (\"import time\\n\"", "cmd = 'import sys;print(sys.path)'", "code2 = (\"from tmp import a\\n\"", "code2 = (\"from tmp import a\\n\"", "'import time\\n'", "'import time\\n'", "'from file1 import f\\n'", "text = (\"import multiprocessing\\n\"", "\"import traceback\\n\"", "text = (\"import multiprocessing\\n\"", "\"import traceback\\n\"", "import multiprocessing", "import sys", "import ctypes; ctypes.string_at(0)", "\"import threading\\n\"", "'import threading\\n'", "import pprint", "shell.execute(\"import ctypes; ctypes.string_at(0)\")", "shell.execute('import time')", "shell.execute('import time')", "shell.execute(\"import sys; sys_path = sys.path\")", "shell1.execute(\"import sys; sys_path = sys.path\")", "s.execute(\"import sys; sys_path = sys.path\")" ]
1,434
1,463
reset_run_code(qtbot, shell, code_editor, nsb) # ---- Run to line ---- # Run lines from file start until, but excluding, current cursor line # Move to line 10 then move one characters into the line and # run lines above editor.go_to_line(10) qtbot.keyClick(code_editor, Qt.Key_Right) run_to_line_action = main_window.run.get_action('run selection up to line') with qtbot.waitSignal(shell.executed): run_to_line_action.trigger() qtbot.wait(500) assert shell.get_value('a') == 10 assert shell.get_value('li') == [1, 2, 3] # Test that lines below did not run assert 'arr' not in nsb.editor.source_model._data.keys() assert 's' not in nsb.editor.source_model._data.keys() reset_run_code(qtbot, shell, code_editor, nsb) # ---- Run from line ---- # Move to line 6, run lines from current cursor line to end # Note that last line (14) will raise a NameError if 'a' is not defined # Set 'a' to a different value before hand to avoid errors in shell shell.execute('a = 100') editor.go_to_line(6) qtbot.keyClick(code_editor, Qt.Key_Right) run_from_line_action = main_window.run.get_action('run selection from line') with qtbot.waitSignal(shell.executed): run_from_line_action.trigger() qtbot.wait(500) assert shell.get_value('s') == "Z:\\escape\\test\\string\n" assert shell.get_value('li') == [1, 2, 3] assert_array_equal(shell.get_value('arr'), np.array([1, 2, 3]))
test_mainwindow.py
spyder.spyder.app.tests
false
false
[ "import gc", "import os", "import os.path as osp", "from pathlib import Path", "import random", "import re", "import shutil", "import sys", "import tempfile", "from textwrap import dedent", "import time", "from unittest.mock import Mock", "import uuid", "from flaky import flaky", "import ipykernel", "from IPython.core import release as ipy_release", "from matplotlib.testing.compare import compare_images", "import nbconvert", "import numpy as np", "from numpy.testing import assert_array_equal", "from packaging.version import parse", "import pylint", "import pytest", "from qtpy import PYQT_VERSION, PYQT5", "from qtpy.QtCore import QPoint, Qt, QTimer", "from qtpy.QtGui import QImage, QTextCursor", "from qtpy.QtWidgets import QAction, QApplication, QInputDialog, QWidget", "from qtpy.QtWebEngineWidgets import WEBENGINE", "from spyder import __trouble_url__", "from spyder.api.utils import get_class_values", "from spyder.api.widgets.auxiliary_widgets import SpyderWindowWidget", "from spyder.api.plugins import Plugins", "from spyder.app.tests.conftest import (", "from spyder.config.base import (", "from spyder.config.manager import CONF", "from spyder.dependencies import DEPENDENCIES", "from spyder.plugins.debugger.api import DebuggerWidgetActions", "from spyder.plugins.externalterminal.api import ExtTerminalShConfiguration", "from spyder.plugins.help.widgets import ObjectComboBox", "from spyder.plugins.help.tests.test_plugin import check_text", "from spyder.plugins.ipythonconsole.utils.kernel_handler import KernelHandler", "from spyder.plugins.ipythonconsole.api import (", "from spyder.plugins.mainmenu.api import ApplicationMenus", "from spyder.plugins.layout.layouts import DefaultLayouts", "from spyder.plugins.toolbar.api import ApplicationToolbars", "from spyder.plugins.run.api import (", "from spyder.py3compat import qbytearray_to_str, to_text_string", "from spyder.utils.environ import set_user_env", "from spyder.utils.misc import remove_backslashes, rename_file", "from spyder.utils.clipboard_helper import CLIPBOARD_HELPER", "from spyder.utils.programs import find_program", "from spyder.widgets.dock import DockTitleBar", "\"import sys\\n\"", "\"from spyder.utils.external import lockfile\\n\"", "shell.execute('import numpy as np; A=np.full(16, np.nan)')", "shell.execute('import numpy as np')", "(\"import numpy as np\", \"An array object of arbitrary homogeneous items\")])", "shell.execute('import os; current_dir = os.getcwd()')", "shell.execute('import os; current_dir = os.getcwd()')", "shell.execute(\"import sys; import os; \"", "shell.execute(\"import sys; import os; \"", "qtbot.keyClicks(control, 'import os; os.getcwd()')", "shell.execute((\"import matplotlib.pyplot as plt\\n\"", "shell.execute((\"import matplotlib.pyplot as plt\\n\"", "\"import time\\n\"", "shell.execute((\"import matplotlib.pyplot as plt\\n\"", "shell.execute((\"import matplotlib.pyplot as plt\\n\"", "from spyder.widgets.collectionseditor import CollectionsEditor", "from spyder.plugins.pylint.main_widget import PylintWidgetActions", "shell.execute('def foo(): import foo')", "code = (\"import time\\n\"", "from qtpy.QtCore import Qt", "code_def = \"import qtpy.QtCore\"", "shell.execute(\"import time\\n\"", "code = (\"import time\\n\"", "cmd = 'import sys;print(sys.path)'", "code2 = (\"from tmp import a\\n\"", "code2 = (\"from tmp import a\\n\"", "'import time\\n'", "'import time\\n'", "'from file1 import f\\n'", "text = (\"import multiprocessing\\n\"", "\"import traceback\\n\"", "text = (\"import multiprocessing\\n\"", "\"import traceback\\n\"", "import multiprocessing", "import sys", "import ctypes; ctypes.string_at(0)", "\"import threading\\n\"", "'import threading\\n'", "import pprint", "shell.execute(\"import ctypes; ctypes.string_at(0)\")", "shell.execute('import time')", "shell.execute('import time')", "shell.execute(\"import sys; sys_path = sys.path\")", "shell1.execute(\"import sys; sys_path = sys.path\")", "s.execute(\"import sys; sys_path = sys.path\")" ]
1,444
1,480
assert shell.get_value('s') == "Z:\\escape\\test\\string\n" assert shell.get_value('li') == [1, 2, 3] assert_array_equal(shell.get_value('arr'), np.array([1, 2, 3])) # Test that lines above did not run, i.e. a is still 100 assert shell.get_value('a') == 100 reset_run_code(qtbot, shell, code_editor, nsb) # ---- Run cell and advance ---- # Run the five cells present in file # Add an unnamed cell at the top of the file qtbot.keyClicks(code_editor, 'a = 10') qtbot.keyClick(code_editor, Qt.Key_Return) qtbot.keyClick(code_editor, Qt.Key_Up) for _ in range(5): with qtbot.waitSignal(shell.executed): qtbot.mouseClick(main_window.run_cell_and_advance_button, Qt.LeftButton) qtbot.wait(500) # Check for errors and the runcell function assert 'runcell' in shell._control.toPlainText() assert 'Error:' not in shell._control.toPlainText() control_text = shell._control.toPlainText() # Rerun shell.setFocus() qtbot.keyClick(shell._control, Qt.Key_Up) qtbot.wait(500) qtbot.keyClick(shell._control, Qt.Key_Enter, modifier=Qt.ShiftModifier) qtbot.wait(500) code_editor.setFocus() assert control_text != shell._control.toPlainText() control_text = shell._control.toPlainText()[len(control_text):] # Check for errors and the runcell function assert 'runcell' in control_text assert 'Error' not in control_text
test_mainwindow.py
spyder.spyder.app.tests
false
false
[ "import gc", "import os", "import os.path as osp", "from pathlib import Path", "import random", "import re", "import shutil", "import sys", "import tempfile", "from textwrap import dedent", "import time", "from unittest.mock import Mock", "import uuid", "from flaky import flaky", "import ipykernel", "from IPython.core import release as ipy_release", "from matplotlib.testing.compare import compare_images", "import nbconvert", "import numpy as np", "from numpy.testing import assert_array_equal", "from packaging.version import parse", "import pylint", "import pytest", "from qtpy import PYQT_VERSION, PYQT5", "from qtpy.QtCore import QPoint, Qt, QTimer", "from qtpy.QtGui import QImage, QTextCursor", "from qtpy.QtWidgets import QAction, QApplication, QInputDialog, QWidget", "from qtpy.QtWebEngineWidgets import WEBENGINE", "from spyder import __trouble_url__", "from spyder.api.utils import get_class_values", "from spyder.api.widgets.auxiliary_widgets import SpyderWindowWidget", "from spyder.api.plugins import Plugins", "from spyder.app.tests.conftest import (", "from spyder.config.base import (", "from spyder.config.manager import CONF", "from spyder.dependencies import DEPENDENCIES", "from spyder.plugins.debugger.api import DebuggerWidgetActions", "from spyder.plugins.externalterminal.api import ExtTerminalShConfiguration", "from spyder.plugins.help.widgets import ObjectComboBox", "from spyder.plugins.help.tests.test_plugin import check_text", "from spyder.plugins.ipythonconsole.utils.kernel_handler import KernelHandler", "from spyder.plugins.ipythonconsole.api import (", "from spyder.plugins.mainmenu.api import ApplicationMenus", "from spyder.plugins.layout.layouts import DefaultLayouts", "from spyder.plugins.toolbar.api import ApplicationToolbars", "from spyder.plugins.run.api import (", "from spyder.py3compat import qbytearray_to_str, to_text_string", "from spyder.utils.environ import set_user_env", "from spyder.utils.misc import remove_backslashes, rename_file", "from spyder.utils.clipboard_helper import CLIPBOARD_HELPER", "from spyder.utils.programs import find_program", "from spyder.widgets.dock import DockTitleBar", "\"import sys\\n\"", "\"from spyder.utils.external import lockfile\\n\"", "shell.execute('import numpy as np; A=np.full(16, np.nan)')", "shell.execute('import numpy as np')", "(\"import numpy as np\", \"An array object of arbitrary homogeneous items\")])", "shell.execute('import os; current_dir = os.getcwd()')", "shell.execute('import os; current_dir = os.getcwd()')", "shell.execute(\"import sys; import os; \"", "shell.execute(\"import sys; import os; \"", "qtbot.keyClicks(control, 'import os; os.getcwd()')", "shell.execute((\"import matplotlib.pyplot as plt\\n\"", "shell.execute((\"import matplotlib.pyplot as plt\\n\"", "\"import time\\n\"", "shell.execute((\"import matplotlib.pyplot as plt\\n\"", "shell.execute((\"import matplotlib.pyplot as plt\\n\"", "from spyder.widgets.collectionseditor import CollectionsEditor", "from spyder.plugins.pylint.main_widget import PylintWidgetActions", "shell.execute('def foo(): import foo')", "code = (\"import time\\n\"", "from qtpy.QtCore import Qt", "code_def = \"import qtpy.QtCore\"", "shell.execute(\"import time\\n\"", "code = (\"import time\\n\"", "cmd = 'import sys;print(sys.path)'", "code2 = (\"from tmp import a\\n\"", "code2 = (\"from tmp import a\\n\"", "'import time\\n'", "'import time\\n'", "'from file1 import f\\n'", "text = (\"import multiprocessing\\n\"", "\"import traceback\\n\"", "text = (\"import multiprocessing\\n\"", "\"import traceback\\n\"", "import multiprocessing", "import sys", "import ctypes; ctypes.string_at(0)", "\"import threading\\n\"", "'import threading\\n'", "import pprint", "shell.execute(\"import ctypes; ctypes.string_at(0)\")", "shell.execute('import time')", "shell.execute('import time')", "shell.execute(\"import sys; sys_path = sys.path\")", "shell1.execute(\"import sys; sys_path = sys.path\")", "s.execute(\"import sys; sys_path = sys.path\")" ]
1,352
1,390