Added an unit test for bug #871.
http://bugs.pyside.org/show_bug.cgi?id=871 Reviewed by Luciano Wolf <luciano.wolf@openbossa.org> Reviewed by Renato Araújo <renato.filho@openbossa.org>
This commit is contained in:
parent
90be657119
commit
b66f8a789a
2 changed files with 42 additions and 0 deletions
|
|
@ -63,6 +63,7 @@ PYSIDE_TEST(bug_844.py)
|
||||||
PYSIDE_TEST(bug_854.py)
|
PYSIDE_TEST(bug_854.py)
|
||||||
PYSIDE_TEST(bug_860.py)
|
PYSIDE_TEST(bug_860.py)
|
||||||
PYSIDE_TEST(bug_862.py)
|
PYSIDE_TEST(bug_862.py)
|
||||||
|
PYSIDE_TEST(bug_871.py)
|
||||||
PYSIDE_TEST(customproxywidget_test.py)
|
PYSIDE_TEST(customproxywidget_test.py)
|
||||||
PYSIDE_TEST(deepcopy_test.py)
|
PYSIDE_TEST(deepcopy_test.py)
|
||||||
PYSIDE_TEST(event_filter_test.py)
|
PYSIDE_TEST(event_filter_test.py)
|
||||||
|
|
|
||||||
41
tests/QtGui/bug_871.py
Normal file
41
tests/QtGui/bug_871.py
Normal file
|
|
@ -0,0 +1,41 @@
|
||||||
|
import unittest
|
||||||
|
from helper import UsesQApplication
|
||||||
|
from PySide.QtGui import QLineEdit, QValidator, QIntValidator
|
||||||
|
|
||||||
|
'''Bug #871 - http://bugs.pyside.org/show_bug.cgi?id=871'''
|
||||||
|
|
||||||
|
|
||||||
|
class BlankIntValidator(QIntValidator):
|
||||||
|
def validate(self,input,pos):
|
||||||
|
if input == '':
|
||||||
|
return QValidator.Acceptable, input, pos
|
||||||
|
else:
|
||||||
|
return QIntValidator.validate(self,input,pos)
|
||||||
|
|
||||||
|
|
||||||
|
class Bug871Test(UsesQApplication):
|
||||||
|
def testWithoutValidator(self):
|
||||||
|
edit = QLineEdit()
|
||||||
|
self.assertEqual(edit.text(), '')
|
||||||
|
edit.insert('1')
|
||||||
|
self.assertEqual(edit.text(), '1')
|
||||||
|
edit.insert('a')
|
||||||
|
self.assertEqual(edit.text(), '1a')
|
||||||
|
edit.insert('2')
|
||||||
|
self.assertEqual(edit.text(), '1a2')
|
||||||
|
|
||||||
|
def testWithIntValidator(self):
|
||||||
|
edit = QLineEdit()
|
||||||
|
edit.setValidator(BlankIntValidator(edit))
|
||||||
|
self.assertEqual(edit.text(), '')
|
||||||
|
edit.insert('1')
|
||||||
|
self.assertEqual(edit.text(), '1')
|
||||||
|
edit.insert('a')
|
||||||
|
self.assertEqual(edit.text(), '1')
|
||||||
|
edit.insert('2')
|
||||||
|
self.assertEqual(edit.text(), '12')
|
||||||
|
|
||||||
|
|
||||||
|
if __name__ == "__main__":
|
||||||
|
unittest.main()
|
||||||
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue