diff --git a/spyder/app/tests/test_mainwindow.py b/spyder/app/tests/test_mainwindow.py index 20719f48b1b..fa5d6856915 100644 --- a/spyder/app/tests/test_mainwindow.py +++ b/spyder/app/tests/test_mainwindow.py @@ -5482,7 +5482,7 @@ def test_console_initial_cwd_is_synced(main_window, qtbot, tmpdir): assert shell.get_cwd() == str(tmpdir) == workdir.get_workdir() == \ files.get_current_folder() - # Check that new clients with a fixed directory + # Check new clients with a fixed directory ipyconsole.set_conf('console/use_cwd', False, section='workingdir') ipyconsole.set_conf( 'console/use_fixed_directory', @@ -5505,6 +5505,29 @@ def test_console_initial_cwd_is_synced(main_window, qtbot, tmpdir): assert shell.get_cwd() == fixed_dir == workdir.get_workdir() == \ files.get_current_folder() + # Check when opening projects + project_path = str(tmpdir.mkdir('test_project')) + main_window.projects.open_project(path=project_path) + qtbot.wait(500) + + shell = ipyconsole.get_current_shellwidget() + qtbot.waitUntil(lambda: shell._prompt_html is not None, + timeout=SHELL_TIMEOUT) + qtbot.wait(500) + assert shell.get_cwd() == project_path == workdir.get_workdir() == \ + files.get_current_folder() + + # Check when closing projects + main_window.projects.close_project() + qtbot.wait(500) + + shell = ipyconsole.get_current_shellwidget() + qtbot.waitUntil(lambda: shell._prompt_html is not None, + timeout=SHELL_TIMEOUT) + qtbot.wait(500) + assert shell.get_cwd() == get_home_dir() == workdir.get_workdir() == \ + files.get_current_folder() + if __name__ == "__main__": pytest.main() diff --git a/spyder/plugins/ipythonconsole/widgets/client.py b/spyder/plugins/ipythonconsole/widgets/client.py index b48ab7d8623..f927b2110ae 100644 --- a/spyder/plugins/ipythonconsole/widgets/client.py +++ b/spyder/plugins/ipythonconsole/widgets/client.py @@ -369,7 +369,6 @@ def _set_initial_cwd_in_kernel(self): cwd_path = get_home_dir() if project_path is not None: cwd_path = project_path - update_in_spyder = False elif self.get_conf( 'startup/use_fixed_directory', section='workingdir'