summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMarcelo Lira <marcelo.lira@openbossa.org>2011-06-09 10:59:24 -0300
committerMarcelo Lira <marcelo.lira@openbossa.org>2011-06-10 18:32:05 -0300
commit1be25c54bb6e4759779347ed609f871311e20ffd (patch)
tree92c47dbfa16b08184a0038873104070a927e6733
parentee602e80f1ccbce91c0203d750df8e9f7d28752b (diff)
downloadpyside-1be25c54bb6e4759779347ed609f871311e20ffd.tar.gz
pyside-1be25c54bb6e4759779347ed609f871311e20ffd.tar.xz
pyside-1be25c54bb6e4759779347ed609f871311e20ffd.zip
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>
-rw-r--r--tests/QtGui/CMakeLists.txt1
-rw-r--r--tests/QtGui/bug_871.py41
2 files changed, 42 insertions, 0 deletions
diff --git a/tests/QtGui/CMakeLists.txt b/tests/QtGui/CMakeLists.txt
index 5aaef04..9afe317 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 0000000..a4fdbbf
--- /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()
+