Skip to content

Commit

Permalink
CI: Revision on slow tests cleanup logic
Browse files Browse the repository at this point in the history
  • Loading branch information
dalthviz committed Oct 11, 2023
1 parent beabdf0 commit cd9110a
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 3 deletions.
2 changes: 2 additions & 0 deletions spyder/api/plugin_registration/registry.py
Original file line number Diff line number Diff line change
Expand Up @@ -794,6 +794,8 @@ def reset(self):
# Omit failures if there are no slots connected
pass

dependencies.DEPENDENCIES = []

def set_all_internal_plugins(
self, all_plugins: Dict[str, Type[SpyderPluginClass]]):
self.all_internal_plugins = all_plugins
Expand Down
26 changes: 23 additions & 3 deletions spyder/app/tests/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
import pytest

# Spyder imports
from spyder.api.plugin_registration.registry import PLUGIN_REGISTRY
from spyder.api.plugins import Plugins
from spyder.app import start
from spyder.config.base import get_home_dir, running_in_ci
Expand Down Expand Up @@ -280,9 +281,12 @@ def close_window():
if hasattr(main_window, 'window') and main_window.window is not None:
window = main_window.window
main_window.window = None
window.closing(close_immediately=True)
window.close()
window = None
CONF.reset_to_defaults(notification=False)
CONF.reset_manager()
PLUGIN_REGISTRY.reset()
if qapp.instance():
qapp.quit()

Expand Down Expand Up @@ -369,9 +373,6 @@ def main_window(request, tmpdir, qtbot):
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
Expand Down Expand Up @@ -443,9 +444,13 @@ def main_window(request, tmpdir, qtbot):
print('info_page')
print(client.info_page)
main_window.window = None
window.closing(close_immediately=True)
window.close()
window = None
CONF.reset_to_defaults(notification=False)
CONF.reset_manager()
PLUGIN_REGISTRY.reset()

else:
# Try to close used mainwindow directly on fixture
# after running test that uses the fixture
Expand All @@ -456,9 +461,12 @@ def main_window(request, tmpdir, qtbot):
'close_main_window')
if close_main_window:
main_window.window = None
window.closing(close_immediately=True)
window.close()
window = None
CONF.reset_to_defaults(notification=False)
CONF.reset_manager()
PLUGIN_REGISTRY.reset()
else:
try:
# Close or hide everything we can think of
Expand Down Expand Up @@ -500,9 +508,12 @@ def main_window(request, tmpdir, qtbot):
window.ipyconsole.restart()
except Exception:
main_window.window = None
window.closing(close_immediately=True)
window.close()
window = None
CONF.reset_to_defaults(notification=False)
CONF.reset_manager()
PLUGIN_REGISTRY.reset()
return

if os.name == 'nt':
Expand Down Expand Up @@ -549,9 +560,12 @@ def threads_condition():
"\nThread " + str(threads) + ":\n")
traceback.print_stack(frame)
main_window.window = None
window.closing(close_immediately=True)
window.close()
window = None
CONF.reset_to_defaults(notification=False)
CONF.reset_manager()
PLUGIN_REGISTRY.reset()
raise

try:
Expand All @@ -562,9 +576,12 @@ def threads_condition():
subprocesses = [repr(f) for f in proc.children()]
show_diff(init_subprocesses, subprocesses, "processes")
main_window.window = None
window.closing(close_immediately=True)
window.close()
window = None
CONF.reset_to_defaults(notification=False)
CONF.reset_manager()
PLUGIN_REGISTRY.reset()
raise

try:
Expand All @@ -578,9 +595,12 @@ def threads_condition():
except Exception:
show_diff(init_files, files, "files")
main_window.window = None
window.closing(close_immediately=True)
window.close()
window = None
CONF.reset_to_defaults(notification=False)
CONF.reset_manager()
PLUGIN_REGISTRY.reset()
raise


Expand Down
5 changes: 5 additions & 0 deletions spyder/config/manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -585,6 +585,11 @@ def reset_to_defaults(self, section=None, notification=True):
else:
self.notify_all_observers()

def reset_manager(self):
for observer in self._observer_map_keys.copy():
self.unobserve_configuration(observer)
self._plugin_configs = {}

# Shortcut configuration management
# ------------------------------------------------------------------------
def _get_shortcut_config(self, context, plugin_name=None):
Expand Down

0 comments on commit cd9110a

Please sign in to comment.