Skip to content
Snippets Groups Projects
Commit 189aea36 authored by Martyn Gigg's avatar Martyn Gigg
Browse files

Garbage collect after each test requiring a qapp

Attempts to fix a random test failure with the jupyter console on
macOS by ensuring that widgets are garbage collected promptly.
Refs #22063
parent 04fd776a
No related merge requests found
......@@ -20,6 +20,7 @@
from __future__ import absolute_import
from inspect import isfunction, ismethod
import gc
from qtpy.QtCore import Qt
from qtpy.QtWidgets import QApplication
......@@ -74,6 +75,7 @@ def _requires_qapp_impl(test_method):
QAPP = QApplication([''])
test_method(self)
QAPP.closeAllWindows()
gc.collect()
return _wrapper
......
......@@ -34,16 +34,18 @@ class InProcessJupyterConsoleTest(unittest.TestCase):
self.assertTrue(hasattr(widget, "kernel_manager"))
self.assertTrue(hasattr(widget, "kernel_client"))
self.assertTrue(len(widget.banner) > 0)
del widget
def test_construction_with_banner_replaces_default(self):
widget = InProcessJupyterConsole(banner="Hello!")
self.assertEquals("Hello!", widget.banner)
del widget
def test_construction_with_startup_code_adds_to_banner_and_executes(self):
widget = InProcessJupyterConsole(startup_code="x = 1")
self.assertTrue("x = 1" in widget.banner)
self.assertEquals(1, widget.kernel_manager.kernel.shell.user_ns['x'])
del widget
if __name__ == '__main__':
unittest.main()
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment