diff options
Diffstat (limited to 'sources/pyside2/tests')
-rw-r--r-- | sources/pyside2/tests/QtWidgets/qvalidator_test.py | 27 | ||||
-rw-r--r-- | sources/pyside2/tests/pysidetest/version_test.py | 6 |
2 files changed, 27 insertions, 6 deletions
diff --git a/sources/pyside2/tests/QtWidgets/qvalidator_test.py b/sources/pyside2/tests/QtWidgets/qvalidator_test.py index 951d6b2b0..dd5eaadb3 100644 --- a/sources/pyside2/tests/QtWidgets/qvalidator_test.py +++ b/sources/pyside2/tests/QtWidgets/qvalidator_test.py @@ -29,38 +29,49 @@ from PySide2.QtCore import * from PySide2.QtGui import * from PySide2.QtWidgets import * +from PySide2.QtTest import * import unittest from helper import UsesQApplication class MyValidator1(QValidator): - def fixUp(self, input): + def fixup(self, input): return "fixed" def validate(self, input, pos): return (QValidator.Acceptable, "fixed", 1) class MyValidator2(QValidator): - def fixUp(self, input): + def fixup(self, input): return "fixed" def validate(self, input, pos): return (QValidator.Acceptable, "fixed") class MyValidator3(QValidator): - def fixUp(self, input): + def fixup(self, input): return "fixed" def validate(self, input, pos): return (QValidator.Acceptable,) class MyValidator4(QValidator): - def fixUp(self, input): + def fixup(self, input): return "fixed" def validate(self, input, pos): return QValidator.Acceptable +class MyValidator5(QValidator): + def validate(self, input, pos): + if input.islower(): + return (QValidator.Intermediate, input, pos) + else: + return (QValidator.Acceptable, input, pos) + + def fixup(self, input): + return "22" + class QValidatorTest(UsesQApplication): def testValidator1(self): line = QLineEdit() @@ -110,5 +121,13 @@ class QValidatorTest(UsesQApplication): self.assertEqual(line.text(), "foo") self.assertEqual(line.cursorPosition(), 3) + def testValidator5(self): + line = QLineEdit() + line.show() + line.setValidator(MyValidator5()) + line.setText("foo") + QTest.keyClick(line, Qt.Key_Return) + self.assertEqual(line.text(), "22") + if __name__ == '__main__': unittest.main() diff --git a/sources/pyside2/tests/pysidetest/version_test.py b/sources/pyside2/tests/pysidetest/version_test.py index 5901a56c1..01e88dbc6 100644 --- a/sources/pyside2/tests/pysidetest/version_test.py +++ b/sources/pyside2/tests/pysidetest/version_test.py @@ -33,8 +33,10 @@ from PySide2 import __version_info__, __version__, QtCore class CheckForVariablesTest(unittest.TestCase): def testVesions(self): - self.assertTrue(__version_info__ >= (1, 0, 0)) - self.assertTrue(__version_info__ < (99, 99, 99)) + version_tuple = (__version_info__[0], __version_info__[1], __version_info__[2]) + self.assertTrue(version_tuple >= (1, 0, 0)) + + self.assertTrue(version_tuple < (99, 99, 99)) self.assertTrue(__version__) self.assertTrue(QtCore.__version_info__ >= (4, 5, 0)) |