From ff90388e354d4833211c6dfba2f0c79f0b2bbf26 Mon Sep 17 00:00:00 2001 From: dalthviz Date: Fri, 4 Feb 2022 14:04:05 -0500 Subject: [PATCH] Testing --- .../plugins/ipythonconsole/tests/test_ipythonconsole.py | 9 +++++---- spyder/plugins/ipythonconsole/widgets/shell.py | 9 ++++----- spyder/plugins/projects/utils/watcher.py | 2 ++ 3 files changed, 11 insertions(+), 9 deletions(-) diff --git a/spyder/plugins/ipythonconsole/tests/test_ipythonconsole.py b/spyder/plugins/ipythonconsole/tests/test_ipythonconsole.py index 6ce9e5eea9b..1e053147012 100644 --- a/spyder/plugins/ipythonconsole/tests/test_ipythonconsole.py +++ b/spyder/plugins/ipythonconsole/tests/test_ipythonconsole.py @@ -1429,7 +1429,8 @@ def test_remove_old_std_files(ipyconsole, qtbot): @flaky(max_runs=10) @pytest.mark.use_startup_wdir -@pytest.mark.skipif(os.name == 'nt', reason="Too flaky on Windows") +@pytest.mark.skipif(sys.platform.startswith('linux'), + reason="Too flaky on Linux") def test_console_working_directory(ipyconsole, qtbot): """Test for checking the working directory.""" shell = ipyconsole.get_current_shellwidget() @@ -1965,11 +1966,10 @@ def test_stop_pdb(ipyconsole, qtbot): @flaky(max_runs=3) -@pytest.mark.skipif(sys.platform == 'nt', reason="Times out on Windows") def test_code_cache(ipyconsole, qtbot): """ Test that code sent to execute is properly cached - and that the cache is empited on interrupt. + and that the cache is emptied on interrupt. """ shell = ipyconsole.get_current_shellwidget() qtbot.waitUntil(lambda: shell._prompt_html is not None, @@ -1987,7 +1987,8 @@ def check_value(name, value): # Send two execute requests and make sure the second one is executed shell.execute('import time; time.sleep(.5)') - shell.execute('var = 142') + with qtbot.waitSignal(shell.executed): + shell.execute('var = 142') qtbot.wait(500) qtbot.waitUntil(lambda: check_value('var', 142)) assert shell.get_value('var') == 142 diff --git a/spyder/plugins/ipythonconsole/widgets/shell.py b/spyder/plugins/ipythonconsole/widgets/shell.py index ff2da1ce82d..86df5b39ca5 100644 --- a/spyder/plugins/ipythonconsole/widgets/shell.py +++ b/spyder/plugins/ipythonconsole/widgets/shell.py @@ -174,17 +174,16 @@ def shutdown(self, shutdown_kernel=True): self.shutting_down = True if shutdown_kernel: self.interrupt_kernel() - self.spyder_kernel_comm.close() self.kernel_manager.stop_restarter() + self.spyder_kernel_comm.close() + if self.kernel_client is not None: + self.kernel_client.stop_channels() shutdown_thread = QThread(self) shutdown_thread.kernel_manager = self.kernel_manager shutdown_thread.run = self.shutdown_kernel - if self.kernel_client is not None: - shutdown_thread.finished.connect( - self.kernel_client.stop_channels) - shutdown_thread.start() self.shutdown_thread_list.append(shutdown_thread) + shutdown_thread.start() else: self.spyder_kernel_comm.close(shutdown_channel=False) if self.kernel_client is not None: diff --git a/spyder/plugins/projects/utils/watcher.py b/spyder/plugins/projects/utils/watcher.py index fe6f21dee3c..f344fa4c870 100644 --- a/spyder/plugins/projects/utils/watcher.py +++ b/spyder/plugins/projects/utils/watcher.py @@ -108,6 +108,7 @@ class WorkspaceWatcher(QObject): """ observer = None + def __init__(self, parent=None): super().__init__(parent) self.event_handler = WorkspaceEventHandler(self) @@ -165,5 +166,6 @@ def stop(self): self.observer.stop() self.observer.join() del self.observer + self.observer = None except RuntimeError: pass