diff options
author | Marcelo Lira <marcelo.lira@openbossa.org> | 2011-06-09 10:59:24 -0300 |
---|---|---|
committer | Hugo Parente Lima <hugo.pl@gmail.com> | 2012-03-08 16:54:28 -0300 |
commit | b66f8a789a55d07ad9fec0d9c40893ecf3952157 (patch) | |
tree | f777beb5cc63dbe9fbdfb1a46db715560ee46f9f /tests | |
parent | 90be65711973543630aae0ce7437f12fefbafcd9 (diff) |
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>
Diffstat (limited to 'tests')
-rw-r--r-- | tests/QtGui/CMakeLists.txt | 1 | ||||
-rw-r--r-- | tests/QtGui/bug_871.py | 41 |
2 files changed, 42 insertions, 0 deletions
diff --git a/tests/QtGui/CMakeLists.txt b/tests/QtGui/CMakeLists.txt index 5aaef045f..9afe3175c 100644 --- a/tests/QtGui/CMakeLists.txt +++ b/tests/QtGui/CMakeLists.txt @@ -63,6 +63,7 @@ PYSIDE_TEST(bug_844.py) PYSIDE_TEST(bug_854.py) PYSIDE_TEST(bug_860.py) PYSIDE_TEST(bug_862.py) +PYSIDE_TEST(bug_871.py) PYSIDE_TEST(customproxywidget_test.py) PYSIDE_TEST(deepcopy_test.py) PYSIDE_TEST(event_filter_test.py) diff --git a/tests/QtGui/bug_871.py b/tests/QtGui/bug_871.py new file mode 100644 index 000000000..a4fdbbfe4 --- /dev/null +++ b/tests/QtGui/bug_871.py @@ -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() + |