File tree Expand file tree Collapse file tree 1 file changed +32
-0
lines changed Expand file tree Collapse file tree 1 file changed +32
-0
lines changed Original file line number Diff line number Diff line change
1
+ from qtpy import QtWidgets
2
+ from qtpy .QtCore import Qt , QTimer
3
+ import unittest
4
+ from mock import patch
5
+ from mslice .app .mainwindow import MainWindow
6
+ from mslice .plotting .globalfiguremanager import GlobalFigureManager
7
+
8
+ qapp = None
9
+
10
+
11
+ class AppTests (unittest .TestCase ):
12
+ def setUp (self ):
13
+ global qapp
14
+ if qapp is None :
15
+ qapp = QtWidgets .QApplication ([" " ])
16
+
17
+ # def tearDown(self):
18
+ # GlobalFigureManager.destroy_all()
19
+
20
+ # Required to sendPostedEvents twice to ensure the MainWindow is deleted
21
+ # qapp.sendPostedEvents()
22
+ # qapp.sendPostedEvents()
23
+
24
+ # There should be no widgets hanging around after the MainWindow is closed
25
+ # self.assertEqual(0, len(QtWidgets.QApplication.topLevelWidgets()))
26
+
27
+ def test_mainwindow (self ):
28
+ """Test the MainWindow initialises correctly"""
29
+ with patch .object (MainWindow , "setup_ipython" ):
30
+ window = MainWindow ()
31
+ window .setAttribute (Qt .WA_DeleteOnClose , True )
32
+ QTimer .singleShot (0 , window .close )
You can’t perform that action at this time.
0 commit comments