source: sasview/src/sas/qtgui/Plotting/UnitTesting/BoxSumTest.py @ b2c8aef

Last change on this file since b2c8aef was 464cd07, checked in by Piotr Rozyczko <rozyczko@…>, 7 years ago

Use singleton QApplication in unit tests to avoid issues on Ubuntu. SASVIEW-485

  • Property mode set to 100644
File size: 1.7 KB
Line 
1import sys
2import unittest
3from mock import MagicMock
4
5from PyQt4 import QtGui
6from PyQt4 import QtCore
7
8# set up import paths
9import path_prepare
10
11# Local
12from sas.qtgui.Plotting.BoxSum import BoxSum
13
14if not QtGui.QApplication.instance():
15    app = QtGui.QApplication(sys.argv)
16
17class BoxSumTest(unittest.TestCase):
18    '''Test the BoxSum'''
19    def setUp(self):
20        '''Create the BoxSum'''
21        # example model
22        model = QtGui.QStandardItemModel()
23        parameters = [1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0]
24        for index, parameter in enumerate(parameters):
25            model.setData(model.index(0, index),
26                    QtCore.QVariant(parameter))
27        self.widget = BoxSum(None, model=model)
28
29    def tearDown(self):
30        '''Destroy the GUI'''
31        self.widget.close()
32        self.widget = None
33
34    def testDefaults(self):
35        '''Test the GUI in its default state'''
36        self.assertIsInstance(self.widget.mapper.mappedWidgetAt(0), QtGui.QLineEdit)
37        self.assertIsInstance(self.widget.mapper.mappedWidgetAt(1), QtGui.QLineEdit)
38        self.assertIsInstance(self.widget.mapper.mappedWidgetAt(2), QtGui.QLineEdit)
39        self.assertIsInstance(self.widget.mapper.mappedWidgetAt(3), QtGui.QLineEdit)
40        self.assertIsInstance(self.widget.mapper.mappedWidgetAt(4), QtGui.QLabel)
41        self.assertIsInstance(self.widget.mapper.mappedWidgetAt(5), QtGui.QLabel)
42        self.assertIsInstance(self.widget.mapper.mappedWidgetAt(6), QtGui.QLabel)
43        self.assertIsInstance(self.widget.mapper.mappedWidgetAt(7), QtGui.QLabel)
44        self.assertIsInstance(self.widget.mapper.mappedWidgetAt(8), QtGui.QLabel)
45       
46       
47if __name__ == "__main__":
48    unittest.main()
Note: See TracBrowser for help on using the repository browser.