From 51143bf33538cc6e9d75225c80d65238b9d2d461 Mon Sep 17 00:00:00 2001 From: Christian Tismer Date: Wed, 14 Mar 2018 15:03:55 +0100 Subject: Correct the test location for minimal builds The tests were partially wrong assigned so that a minimal build with "--module-subset=QtCore,QtGui,QtWidgets" had unnecessary errors. This patch re-arranges the tests accordingly. Change-Id: I48e37875dd8856707df41f5943ce9435851f2d03 Reviewed-by: Friedemann Kleint --- sources/pyside2/tests/QtGui/CMakeLists.txt | 1 - sources/pyside2/tests/QtGui/bug_500.py | 43 ------- .../pyside2/tests/QtPrintSupport/CMakeLists.txt | 3 +- sources/pyside2/tests/QtPrintSupport/bug_500.py | 43 +++++++ .../returnquadruplesofnumbers_test.py | 95 +++++++++++++++ sources/pyside2/tests/QtTest/CMakeLists.txt | 1 + sources/pyside2/tests/QtTest/qvalidator_test.py | 133 +++++++++++++++++++++ sources/pyside2/tests/QtWidgets/CMakeLists.txt | 2 - sources/pyside2/tests/QtWidgets/qvalidator_test.py | 133 --------------------- .../QtWidgets/returnquadruplesofnumbers_test.py | 95 --------------- 10 files changed, 274 insertions(+), 275 deletions(-) delete mode 100644 sources/pyside2/tests/QtGui/bug_500.py create mode 100644 sources/pyside2/tests/QtPrintSupport/bug_500.py create mode 100644 sources/pyside2/tests/QtPrintSupport/returnquadruplesofnumbers_test.py create mode 100644 sources/pyside2/tests/QtTest/qvalidator_test.py delete mode 100644 sources/pyside2/tests/QtWidgets/qvalidator_test.py delete mode 100644 sources/pyside2/tests/QtWidgets/returnquadruplesofnumbers_test.py (limited to 'sources/pyside2') diff --git a/sources/pyside2/tests/QtGui/CMakeLists.txt b/sources/pyside2/tests/QtGui/CMakeLists.txt index eeb7c7e36..b487a2401 100644 --- a/sources/pyside2/tests/QtGui/CMakeLists.txt +++ b/sources/pyside2/tests/QtGui/CMakeLists.txt @@ -3,7 +3,6 @@ PYSIDE_TEST(bug_300_test.py) PYSIDE_TEST(bug_367.py) PYSIDE_TEST(bug_480.py) -PYSIDE_TEST(bug_500.py) PYSIDE_TEST(bug_606.py) PYSIDE_TEST(bug_617.py) PYSIDE_TEST(bug_652.py) diff --git a/sources/pyside2/tests/QtGui/bug_500.py b/sources/pyside2/tests/QtGui/bug_500.py deleted file mode 100644 index b6f941633..000000000 --- a/sources/pyside2/tests/QtGui/bug_500.py +++ /dev/null @@ -1,43 +0,0 @@ -#!/usr/bin/python - -############################################################################# -## -## Copyright (C) 2016 The Qt Company Ltd. -## Contact: https://www.qt.io/licensing/ -## -## This file is part of the test suite of PySide2. -## -## $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$ -## -############################################################################# - -import unittest - -from PySide2.QtCore import * -from PySide2.QtPrintSupport import * -from helper import UsesQApplication - -class NeverDiesTest(UsesQApplication): - - def testIt(self): - QPrintDialog() - -if __name__ == "__main__": - unittest.main() diff --git a/sources/pyside2/tests/QtPrintSupport/CMakeLists.txt b/sources/pyside2/tests/QtPrintSupport/CMakeLists.txt index 2f7cb08b9..510c5fe0b 100644 --- a/sources/pyside2/tests/QtPrintSupport/CMakeLists.txt +++ b/sources/pyside2/tests/QtPrintSupport/CMakeLists.txt @@ -1 +1,2 @@ -# Please add some tests, here +PYSIDE_TEST(bug_500.py) +PYSIDE_TEST(returnquadruplesofnumbers_test.py) diff --git a/sources/pyside2/tests/QtPrintSupport/bug_500.py b/sources/pyside2/tests/QtPrintSupport/bug_500.py new file mode 100644 index 000000000..b6f941633 --- /dev/null +++ b/sources/pyside2/tests/QtPrintSupport/bug_500.py @@ -0,0 +1,43 @@ +#!/usr/bin/python + +############################################################################# +## +## Copyright (C) 2016 The Qt Company Ltd. +## Contact: https://www.qt.io/licensing/ +## +## This file is part of the test suite of PySide2. +## +## $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$ +## +############################################################################# + +import unittest + +from PySide2.QtCore import * +from PySide2.QtPrintSupport import * +from helper import UsesQApplication + +class NeverDiesTest(UsesQApplication): + + def testIt(self): + QPrintDialog() + +if __name__ == "__main__": + unittest.main() diff --git a/sources/pyside2/tests/QtPrintSupport/returnquadruplesofnumbers_test.py b/sources/pyside2/tests/QtPrintSupport/returnquadruplesofnumbers_test.py new file mode 100644 index 000000000..6e4cfeb63 --- /dev/null +++ b/sources/pyside2/tests/QtPrintSupport/returnquadruplesofnumbers_test.py @@ -0,0 +1,95 @@ +############################################################################# +## +## Copyright (C) 2016 The Qt Company Ltd. +## Contact: https://www.qt.io/licensing/ +## +## This file is part of the test suite of PySide2. +## +## $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$ +## +############################################################################# + +from __future__ import print_function + +import unittest +from PySide2.QtGui import QTextCursor +from PySide2.QtPrintSupport import QPrinter +from PySide2.QtWidgets import QLayout, QWidget, QGraphicsLayout, QGraphicsLayoutItem + +from helper import UsesQApplication + +class Layout(QLayout): + def __init__(self): + QLayout.__init__(self) + +class GraphicsLayout(QGraphicsLayout): + def __init__(self): + QGraphicsLayout.__init__(self) + +class GraphicsLayoutItem(QGraphicsLayoutItem): + def __init__(self): + QGraphicsLayoutItem.__init__(self) + +class ReturnsQuadruplesOfNumbers(UsesQApplication): + def compareTuples(self, ta, tb): + for va,vb in zip(ta, tb): + if round(va) != round(vb): + return False + return True + + def testQGraphicsLayoutGetContentsMargins(self): + obj = GraphicsLayout() + values = (10.0, 20.0, 30.0, 40.0) + obj.setContentsMargins(*values) + self.assertTrue(self.compareTuples(obj.getContentsMargins(), values)) + + def testQGraphicsLayoutItemGetContentsMargins(self): + obj = GraphicsLayoutItem() + self.assertTrue(self.compareTuples(obj.getContentsMargins(), (0.0, 0.0, 0.0, 0.0))) + + def testQWidgetGetContentsMargins(self): + obj = QWidget() + values = (10, 20, 30, 40) + obj.setContentsMargins(*values) + self.assertTrue(self.compareTuples(obj.getContentsMargins(), values)) + + def testQLayoutGetContentsMargins(self): + obj = Layout() + values = (10, 20, 30, 40) + obj.setContentsMargins(*values) + self.assertTrue(self.compareTuples(obj.getContentsMargins(), values)) + + def testQTextCursorSelectedTableCells(self): + obj = QTextCursor() + self.assertEqual(obj.selectedTableCells(), (-1, -1, -1, -1)) + + def testQPrinterGetPageMargins(self): + # Bug #742 + obj = QPrinter() + # On macOS the minimum margin of a page is ~12, setting something lower than that will + # actually fail to set all the margins. + values = (15.0, 16.0, 17.0, 18.0, QPrinter.Point) + obj.setPageMargins(*values) + print(obj.getPageMargins(QPrinter.Point), values[:-1]) + self.assertTrue(self.compareTuples(obj.getPageMargins(QPrinter.Point), values[:-1])) + +if __name__ == "__main__": + unittest.main() + diff --git a/sources/pyside2/tests/QtTest/CMakeLists.txt b/sources/pyside2/tests/QtTest/CMakeLists.txt index 2a95b70f7..cf72dfa5c 100644 --- a/sources/pyside2/tests/QtTest/CMakeLists.txt +++ b/sources/pyside2/tests/QtTest/CMakeLists.txt @@ -2,3 +2,4 @@ PYSIDE_TEST(click_test.py) PYSIDE_TEST(eventfilter_test.py) # The test is currently permanently broken, needs to be fixed. #PYSIDE_TEST(touchevent_test.py) +PYSIDE_TEST(qvalidator_test.py) diff --git a/sources/pyside2/tests/QtTest/qvalidator_test.py b/sources/pyside2/tests/QtTest/qvalidator_test.py new file mode 100644 index 000000000..dd5eaadb3 --- /dev/null +++ b/sources/pyside2/tests/QtTest/qvalidator_test.py @@ -0,0 +1,133 @@ +############################################################################# +## +## Copyright (C) 2016 The Qt Company Ltd. +## Contact: https://www.qt.io/licensing/ +## +## This file is part of the test suite of PySide2. +## +## $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$ +## +############################################################################# + +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): + return "fixed" + + def validate(self, input, pos): + return (QValidator.Acceptable, "fixed", 1) + +class MyValidator2(QValidator): + def fixup(self, input): + return "fixed" + + def validate(self, input, pos): + return (QValidator.Acceptable, "fixed") + +class MyValidator3(QValidator): + def fixup(self, input): + return "fixed" + + def validate(self, input, pos): + return (QValidator.Acceptable,) + +class MyValidator4(QValidator): + 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() + line.setValidator(MyValidator1()) + line.show() + line.setText("foo") + + QTimer.singleShot(0, line.close) + self.app.exec_() + + self.assertEqual(line.text(), "fixed") + self.assertEqual(line.cursorPosition(), 1) + + def testValidator2(self): + line = QLineEdit() + line.setValidator(MyValidator2()) + line.show() + line.setText("foo") + + QTimer.singleShot(0, line.close) + self.app.exec_() + + self.assertEqual(line.text(), "fixed") + self.assertEqual(line.cursorPosition(), 3) + + def testValidator3(self): + line = QLineEdit() + line.setValidator(MyValidator3()) + line.show() + line.setText("foo") + + QTimer.singleShot(0, line.close) + self.app.exec_() + + self.assertEqual(line.text(), "foo") + self.assertEqual(line.cursorPosition(), 3) + + def testValidator4(self): + line = QLineEdit() + line.setValidator(MyValidator4()) + line.show() + line.setText("foo") + + QTimer.singleShot(0, line.close) + self.app.exec_() + + 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/QtWidgets/CMakeLists.txt b/sources/pyside2/tests/QtWidgets/CMakeLists.txt index 4efd9d803..fa64d1c3b 100644 --- a/sources/pyside2/tests/QtWidgets/CMakeLists.txt +++ b/sources/pyside2/tests/QtWidgets/CMakeLists.txt @@ -123,13 +123,11 @@ PYSIDE_TEST(qtextedit_signal_test.py) PYSIDE_TEST(qtreeview_test.py) PYSIDE_TEST(qtoolbar_test.py) PYSIDE_TEST(qtoolbox_test.py) -PYSIDE_TEST(qvalidator_test.py) PYSIDE_TEST(qvariant_test.py) PYSIDE_TEST(qwidget_setlayout_test.py) PYSIDE_TEST(qwidget_test.py) PYSIDE_TEST(qcolormap_test.py) PYSIDE_TEST(reference_count_test.py) -PYSIDE_TEST(returnquadruplesofnumbers_test.py) PYSIDE_TEST(standardpixmap_test.py) PYSIDE_TEST(test_module_template.py) PYSIDE_TEST(virtual_protected_inheritance_test.py) diff --git a/sources/pyside2/tests/QtWidgets/qvalidator_test.py b/sources/pyside2/tests/QtWidgets/qvalidator_test.py deleted file mode 100644 index dd5eaadb3..000000000 --- a/sources/pyside2/tests/QtWidgets/qvalidator_test.py +++ /dev/null @@ -1,133 +0,0 @@ -############################################################################# -## -## Copyright (C) 2016 The Qt Company Ltd. -## Contact: https://www.qt.io/licensing/ -## -## This file is part of the test suite of PySide2. -## -## $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$ -## -############################################################################# - -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): - return "fixed" - - def validate(self, input, pos): - return (QValidator.Acceptable, "fixed", 1) - -class MyValidator2(QValidator): - def fixup(self, input): - return "fixed" - - def validate(self, input, pos): - return (QValidator.Acceptable, "fixed") - -class MyValidator3(QValidator): - def fixup(self, input): - return "fixed" - - def validate(self, input, pos): - return (QValidator.Acceptable,) - -class MyValidator4(QValidator): - 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() - line.setValidator(MyValidator1()) - line.show() - line.setText("foo") - - QTimer.singleShot(0, line.close) - self.app.exec_() - - self.assertEqual(line.text(), "fixed") - self.assertEqual(line.cursorPosition(), 1) - - def testValidator2(self): - line = QLineEdit() - line.setValidator(MyValidator2()) - line.show() - line.setText("foo") - - QTimer.singleShot(0, line.close) - self.app.exec_() - - self.assertEqual(line.text(), "fixed") - self.assertEqual(line.cursorPosition(), 3) - - def testValidator3(self): - line = QLineEdit() - line.setValidator(MyValidator3()) - line.show() - line.setText("foo") - - QTimer.singleShot(0, line.close) - self.app.exec_() - - self.assertEqual(line.text(), "foo") - self.assertEqual(line.cursorPosition(), 3) - - def testValidator4(self): - line = QLineEdit() - line.setValidator(MyValidator4()) - line.show() - line.setText("foo") - - QTimer.singleShot(0, line.close) - self.app.exec_() - - 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/QtWidgets/returnquadruplesofnumbers_test.py b/sources/pyside2/tests/QtWidgets/returnquadruplesofnumbers_test.py deleted file mode 100644 index 6e4cfeb63..000000000 --- a/sources/pyside2/tests/QtWidgets/returnquadruplesofnumbers_test.py +++ /dev/null @@ -1,95 +0,0 @@ -############################################################################# -## -## Copyright (C) 2016 The Qt Company Ltd. -## Contact: https://www.qt.io/licensing/ -## -## This file is part of the test suite of PySide2. -## -## $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$ -## -############################################################################# - -from __future__ import print_function - -import unittest -from PySide2.QtGui import QTextCursor -from PySide2.QtPrintSupport import QPrinter -from PySide2.QtWidgets import QLayout, QWidget, QGraphicsLayout, QGraphicsLayoutItem - -from helper import UsesQApplication - -class Layout(QLayout): - def __init__(self): - QLayout.__init__(self) - -class GraphicsLayout(QGraphicsLayout): - def __init__(self): - QGraphicsLayout.__init__(self) - -class GraphicsLayoutItem(QGraphicsLayoutItem): - def __init__(self): - QGraphicsLayoutItem.__init__(self) - -class ReturnsQuadruplesOfNumbers(UsesQApplication): - def compareTuples(self, ta, tb): - for va,vb in zip(ta, tb): - if round(va) != round(vb): - return False - return True - - def testQGraphicsLayoutGetContentsMargins(self): - obj = GraphicsLayout() - values = (10.0, 20.0, 30.0, 40.0) - obj.setContentsMargins(*values) - self.assertTrue(self.compareTuples(obj.getContentsMargins(), values)) - - def testQGraphicsLayoutItemGetContentsMargins(self): - obj = GraphicsLayoutItem() - self.assertTrue(self.compareTuples(obj.getContentsMargins(), (0.0, 0.0, 0.0, 0.0))) - - def testQWidgetGetContentsMargins(self): - obj = QWidget() - values = (10, 20, 30, 40) - obj.setContentsMargins(*values) - self.assertTrue(self.compareTuples(obj.getContentsMargins(), values)) - - def testQLayoutGetContentsMargins(self): - obj = Layout() - values = (10, 20, 30, 40) - obj.setContentsMargins(*values) - self.assertTrue(self.compareTuples(obj.getContentsMargins(), values)) - - def testQTextCursorSelectedTableCells(self): - obj = QTextCursor() - self.assertEqual(obj.selectedTableCells(), (-1, -1, -1, -1)) - - def testQPrinterGetPageMargins(self): - # Bug #742 - obj = QPrinter() - # On macOS the minimum margin of a page is ~12, setting something lower than that will - # actually fail to set all the margins. - values = (15.0, 16.0, 17.0, 18.0, QPrinter.Point) - obj.setPageMargins(*values) - print(obj.getPageMargins(QPrinter.Point), values[:-1]) - self.assertTrue(self.compareTuples(obj.getPageMargins(QPrinter.Point), values[:-1])) - -if __name__ == "__main__": - unittest.main() - -- cgit v1.2.3