aboutsummaryrefslogtreecommitdiffstats
path: root/tests/QtGui/bug_879.py
blob: 6261ead20cee7b2a1e228b37d91b7761d490ec8f (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
import unittest
from PySide.QtCore import *
from PySide.QtGui import *

class MySpinBox(QSpinBox):

    def validate(self,text,pos):
        return QSpinBox.validate(self,text,pos)

class TestBug879 (unittest.TestCase):

    def testIt(self):
        app = QApplication([])
        self.box = MySpinBox()
        self.box.show()

        QTimer.singleShot(0, self.sendKbdEvent)
        QTimer.singleShot(100, app.quit)
        app.exec_()

        self.assertEqual(self.box.text(), '0')

    def sendKbdEvent(self):
        ev = QKeyEvent(QEvent.KeyPress, Qt.Key_A, Qt.NoModifier, 'a')
        QCoreApplication.sendEvent(self.box, ev)

if __name__ == '__main__':
    unittest.main()