diff options
Diffstat (limited to 'sources/pyside6/tests/QtTest/qvalidator_test.py')
-rw-r--r-- | sources/pyside6/tests/QtTest/qvalidator_test.py | 53 |
1 files changed, 17 insertions, 36 deletions
diff --git a/sources/pyside6/tests/QtTest/qvalidator_test.py b/sources/pyside6/tests/QtTest/qvalidator_test.py index 0f69e38d6..2382b8605 100644 --- a/sources/pyside6/tests/QtTest/qvalidator_test.py +++ b/sources/pyside6/tests/QtTest/qvalidator_test.py @@ -1,30 +1,5 @@ -############################################################################# -## -## Copyright (C) 2016 The Qt Company Ltd. -## Contact: https://www.qt.io/licensing/ -## -## This file is part of the test suite of Qt for Python. -## -## $QT_BEGIN_LICENSE:GPL-EXCEPT$ -## Commercial License Usage -## Licensees holding valid commercial Qt licenses may use this file in -## accordance with the commercial license agreement provided with the -## Software or, alternatively, in accordance with the terms contained in -## a written agreement between you and The Qt Company. For licensing terms -## and conditions see https://www.qt.io/terms-conditions. For further -## information use the contact form at https://www.qt.io/contact-us. -## -## GNU General Public License Usage -## Alternatively, this file may be used under the terms of the GNU -## General Public License version 3 as published by the Free Software -## Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT -## included in the packaging of this file. Please review the following -## information to ensure the GNU General Public License requirements will -## be met: https://www.gnu.org/licenses/gpl-3.0.html. -## -## $QT_END_LICENSE$ -## -############################################################################# +# Copyright (C) 2022 The Qt Company Ltd. +# SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0 import os import sys @@ -35,13 +10,13 @@ sys.path.append(os.fspath(Path(__file__).resolve().parents[1])) from init_paths import init_test_paths init_test_paths(False) -from PySide6.QtCore import * -from PySide6.QtGui import * -from PySide6.QtWidgets import * -from PySide6.QtTest import * - +from PySide6.QtCore import QTimer, Qt +from PySide6.QtGui import QValidator +from PySide6.QtWidgets import QLineEdit +from PySide6.QtTest import QTest from helper.usesqapplication import UsesQApplication + class MyValidator1(QValidator): def fixup(self, input): return "fixed" @@ -49,6 +24,7 @@ class MyValidator1(QValidator): def validate(self, input, pos): return (QValidator.Acceptable, "fixed", 1) + class MyValidator2(QValidator): def fixup(self, input): return "fixed" @@ -56,6 +32,7 @@ class MyValidator2(QValidator): def validate(self, input, pos): return (QValidator.Acceptable, "fixed") + class MyValidator3(QValidator): def fixup(self, input): return "fixed" @@ -63,6 +40,7 @@ class MyValidator3(QValidator): def validate(self, input, pos): return (QValidator.Acceptable,) + class MyValidator4(QValidator): def fixup(self, input): return "fixed" @@ -70,6 +48,7 @@ class MyValidator4(QValidator): def validate(self, input, pos): return QValidator.Acceptable + class MyValidator5(QValidator): def validate(self, input, pos): if input.islower(): @@ -80,6 +59,7 @@ class MyValidator5(QValidator): def fixup(self, input): return "22" + class QValidatorTest(UsesQApplication): def testValidator1(self): line = QLineEdit() @@ -88,7 +68,7 @@ class QValidatorTest(UsesQApplication): line.setText("foo") QTimer.singleShot(0, line.close) - self.app.exec_() + self.app.exec() self.assertEqual(line.text(), "fixed") self.assertEqual(line.cursorPosition(), 1) @@ -100,7 +80,7 @@ class QValidatorTest(UsesQApplication): line.setText("foo") QTimer.singleShot(0, line.close) - self.app.exec_() + self.app.exec() self.assertEqual(line.text(), "fixed") self.assertEqual(line.cursorPosition(), 3) @@ -112,7 +92,7 @@ class QValidatorTest(UsesQApplication): line.setText("foo") QTimer.singleShot(0, line.close) - self.app.exec_() + self.app.exec() self.assertEqual(line.text(), "foo") self.assertEqual(line.cursorPosition(), 3) @@ -124,7 +104,7 @@ class QValidatorTest(UsesQApplication): line.setText("foo") QTimer.singleShot(0, line.close) - self.app.exec_() + self.app.exec() self.assertEqual(line.text(), "foo") self.assertEqual(line.cursorPosition(), 3) @@ -137,5 +117,6 @@ class QValidatorTest(UsesQApplication): QTest.keyClick(line, Qt.Key_Return) self.assertEqual(line.text(), "22") + if __name__ == '__main__': unittest.main() |