Skip to content

Commit

Permalink
Testing
Browse files Browse the repository at this point in the history
  • Loading branch information
dalthviz committed Feb 3, 2022
1 parent c2f06fc commit 5f2e2e3
Show file tree
Hide file tree
Showing 12 changed files with 37 additions and 33 deletions.
4 changes: 4 additions & 0 deletions spyder/api/widgets/status.py
Original file line number Diff line number Diff line change
Expand Up @@ -218,6 +218,10 @@ def __init__(self, parent=None):
self.timer.timeout.connect(self.update_status)
self.timer.start(self._interval)

def closeEvent(self, event):
self.timer.stop()
super().closeEvent(event)

# ---- Qt API
def setVisible(self, value):
"""Override Qt method to stops timers if widget is not visible."""
Expand Down
1 change: 1 addition & 0 deletions spyder/app/mainwindow.py
Original file line number Diff line number Diff line change
Expand Up @@ -1458,6 +1458,7 @@ def set_splash(self, message):
def closeEvent(self, event):
"""closeEvent reimplementation"""
if self.closing(True):
QApplication.processEvents()
event.accept()
else:
event.ignore()
Expand Down
2 changes: 1 addition & 1 deletion spyder/app/tests/test_mainwindow.py
Original file line number Diff line number Diff line change
Expand Up @@ -352,7 +352,7 @@ def main_window(request, tmpdir, qtbot):
if client.info_page != client.blank_page:
print('info_page')
print(client.info_page)
window.closing(cancelable=False, close_immediately=True)
# window.closing(cancelable=False, close_immediately=True)
window.close()
del main_window.window
else:
Expand Down
4 changes: 2 additions & 2 deletions spyder/plugins/editor/widgets/status.py
Original file line number Diff line number Diff line change
Expand Up @@ -91,8 +91,8 @@ def __init__(self, parent):

# ---- Qt reimplemented
def closeEvent(self, event):
self._worker_manager.terminate_all()
super().closeEvent(event)
self._worker_manager.terminate_all()

def update_vcs_state(self, idx, fname, fname2):
"""Update vcs status."""
Expand All @@ -114,7 +114,7 @@ def update_vcs(self, fname, index, force=False):
self._last_git_job = (fname, index)
self._git_job_queue = None
self._git_is_working = True
#worker.start()
worker.start()

def get_git_refs(self, fname):
"""Get Git active branch, state, branches (plus tags)."""
Expand Down
4 changes: 2 additions & 2 deletions spyder/plugins/editor/widgets/tests/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -227,9 +227,9 @@ def codeeditor(qtbot):
scroll_past_end=True)
widget.setup_editor(language='Python')
widget.resize(640, 480)
qtbot.addWidget(widget)
widget.show()
return widget
yield widget
widget.close()


@pytest.fixture
Expand Down
3 changes: 0 additions & 3 deletions spyder/plugins/ipythonconsole/tests/test_ipythonconsole.py
Original file line number Diff line number Diff line change
Expand Up @@ -204,9 +204,6 @@ def __getattr__(self, attr):
# Set exclamation mark to True
configuration.set('ipython_console', 'pdb_use_exclamation_mark', True)

# This segfaults on macOS
if not sys.platform == "darwin":
qtbot.addWidget(window)
window.resize(640, 480)
window.show()

Expand Down
4 changes: 4 additions & 0 deletions spyder/plugins/ipythonconsole/widgets/main_widget.py
Original file line number Diff line number Diff line change
Expand Up @@ -373,6 +373,10 @@ def __init__(self, name=None, plugin=None, parent=None,
# See spyder-ide/spyder#11880
self._init_asyncio_patch()

def on_close(self):
self.mainwindow_close = True
self.close_clients()

# ---- PluginMainWidget API and settings handling
# ------------------------------------------------------------------------
def get_title(self):
Expand Down
3 changes: 3 additions & 0 deletions spyder/plugins/maininterpreter/container.py
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,9 @@ def section_conf_update(self, option, value):
osp.isfile(executable)):
self.sig_add_to_custom_interpreters_requested.emit(executable)

def on_close(self):
self.interpreter_status.close()

# ---- Public API
def get_main_interpreter(self):
if self.get_conf('default'):
Expand Down
1 change: 1 addition & 0 deletions spyder/plugins/maininterpreter/widgets/status.py
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,7 @@ def get_icon(self):

# ---- Qt reimplemented
def closeEvent(self, event):
self._get_envs_timer.stop()
self._worker_manager.terminate_all()
super().closeEvent(event)

Expand Down
12 changes: 5 additions & 7 deletions spyder/plugins/onlinehelp/tests/test_pydocgui.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,14 +27,12 @@ def pydocbrowser(qtbot):
plugin_mock = MagicMock()
plugin_mock.CONF_SECTION = 'onlinehelp'
widget = PydocBrowser(parent=None, plugin=plugin_mock, name='pydoc')
qtbot.addWidget(widget)
widget._setup()
widget.setup()
widget.resize(640, 480)
widget.show()

with qtbot.waitSignal(widget.sig_load_finished, timeout=20000):
widget.initialize()
widget._setup()
widget.setup()
widget.resize(640, 480)
widget.show()
widget.initialize(force=True)
yield widget
widget.close()

Expand Down
28 changes: 12 additions & 16 deletions spyder/plugins/onlinehelp/widgets.py
Original file line number Diff line number Diff line change
Expand Up @@ -123,8 +123,6 @@ def quit_server(self):

if self.server.serving:
self.server.stop()
self.quit()
self.wait()


class PydocBrowser(PluginMainWidget):
Expand Down Expand Up @@ -297,16 +295,9 @@ def _handle_icon_change(self):
# --- Qt overrides
# ------------------------------------------------------------------------
def closeEvent(self, event):
# Process pending event before closing.
# Prevents showing warnings regarding WebEnginePage not being deleted:
# `Release of profile requested but WebEnginePage still not deleted.
# Expect troubles !`
QApplication.processEvents()
try:
self.server.quit_server()
except AttributeError:
pass
event.accept()
self.webview.web_widget.stop()
self.quit_server()
super().closeEvent(event)

# --- Public API
# ------------------------------------------------------------------------
Expand All @@ -322,7 +313,7 @@ def load_history(self, history):
self.url_combo.addItems(history)

@Slot(bool)
def initialize(self, checked=True):
def initialize(self, checked=True, force=False):
"""
Start pydoc server.
Expand All @@ -332,11 +323,14 @@ def initialize(self, checked=True):
This method is connected to the `sig_toggle_view_changed` signal,
so that the first time the widget is made visible it will start
the server. Default is True.
force: bool, optional
Force a server start even if the server is running.
Default is False.
"""
if checked and self.server is None:
if force or (checked and self.server is None
or not self.server.is_running()):
self.sig_toggle_view_changed.disconnect(self.initialize)
QApplication.setOverrideCursor(QCursor(Qt.WaitCursor))
QApplication.processEvents()
self.start_server()

def is_server_running(self):
Expand All @@ -347,10 +341,11 @@ def start_server(self):
"""Start pydoc server."""
if self.server is None:
self.set_home_url('http://127.0.0.1:{}/'.format(PORT))
elif self.server.isRunning():
elif self.server.is_running():
self.server.sig_server_started.disconnect(
self._continue_initialization)
self.server.quit()
self.server.wait()

self.server = PydocServer(self, port=PORT)
self.server.sig_server_started.connect(
Expand All @@ -367,6 +362,7 @@ def quit_server(self):
self._continue_initialization)
self.server.quit_server()
self.server.quit()
self.server.wait()

def get_label(self):
"""Return address label text"""
Expand Down
4 changes: 2 additions & 2 deletions spyder/plugins/projects/utils/watcher.py
Original file line number Diff line number Diff line change
Expand Up @@ -108,8 +108,8 @@ class WorkspaceWatcher(QObject):
"""

def __init__(self, parent=None):
super().__init__(parent)
self.observer = None
super().__init__(parent)
self.event_handler = WorkspaceEventHandler(self)

def connect_signals(self, project):
Expand All @@ -131,6 +131,7 @@ def start(self, workspace_folder):
# This error happens frequently on Linux
logger.debug("Watcher could not be started.")
except OSError as e:
self.observer = None
if u'inotify' in to_text_string(e):
QMessageBox.warning(
self.parent(),
Expand All @@ -152,7 +153,6 @@ def start(self, workspace_folder):
"<br><br>"
"After doing that, you need to close and start Spyder "
"again so those changes can take effect."))
self.observer = None
else:
raise e

Expand Down

0 comments on commit 5f2e2e3

Please sign in to comment.