Skip to content

Commit dd0a934

Browse files
committed
Only remove tearDown
1 parent 64aac9d commit dd0a934

File tree

1 file changed

+32
-0
lines changed

1 file changed

+32
-0
lines changed

tests/app_test.py

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
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)

0 commit comments

Comments
 (0)