diff options
author | Friedemann Kleint <Friedemann.Kleint@qt.io> | 2019-11-04 12:34:17 +0100 |
---|---|---|
committer | Friedemann Kleint <Friedemann.Kleint@qt.io> | 2019-11-04 12:42:35 +0100 |
commit | 1704567d7ad0d21dd3b588af7aad40cd244c1799 (patch) | |
tree | 932b42988e482f01125dcbf4d470e9a56107689a /sources/pyside2/tests/QtCore | |
parent | 1d77cd18510412242384c5b37a00efd5b6ce8a26 (diff) | |
parent | c98ef56544cd54661b61529829caf6a799a1a94f (diff) |
Merge "Merge remote-tracking branch 'origin/5.14' into 5.15"
Diffstat (limited to 'sources/pyside2/tests/QtCore')
-rw-r--r-- | sources/pyside2/tests/QtCore/CMakeLists.txt | 3 | ||||
-rw-r--r-- | sources/pyside2/tests/QtCore/attr_cache_py3k.py | 6 | ||||
-rw-r--r-- | sources/pyside2/tests/QtCore/qcalendar_test.py | 47 | ||||
-rw-r--r-- | sources/pyside2/tests/QtCore/qsettings_test.py | 46 |
4 files changed, 96 insertions, 6 deletions
diff --git a/sources/pyside2/tests/QtCore/CMakeLists.txt b/sources/pyside2/tests/QtCore/CMakeLists.txt index d05699f16..35e42e2ae 100644 --- a/sources/pyside2/tests/QtCore/CMakeLists.txt +++ b/sources/pyside2/tests/QtCore/CMakeLists.txt @@ -52,6 +52,9 @@ PYSIDE_TEST(qbytearray_concatenation_operator_test.py) PYSIDE_TEST(qbytearray_operator_iadd_test.py) PYSIDE_TEST(qbytearray_operator_test.py) PYSIDE_TEST(qbytearray_test.py) +if (Qt5Core_VERSION VERSION_EQUAL 5.14.0 OR Qt5Core_VERSION VERSION_GREATER 5.14.0) + PYSIDE_TEST(qcalendar_test.py) +endif() PYSIDE_TEST(qcbor_test.py) PYSIDE_TEST(qcollator_test.py) PYSIDE_TEST(qcommandlineparser_test.py) diff --git a/sources/pyside2/tests/QtCore/attr_cache_py3k.py b/sources/pyside2/tests/QtCore/attr_cache_py3k.py index ec0575b02..f9761a9d3 100644 --- a/sources/pyside2/tests/QtCore/attr_cache_py3k.py +++ b/sources/pyside2/tests/QtCore/attr_cache_py3k.py @@ -56,9 +56,9 @@ class A(QObject): def test(cls): cls.instance cls.instance = cls() - assert "<__main__.A object " in repr(cls.__dict__['instance']) - assert "<__main__.A object " in repr(cls.instance) - assert "<__main__.A object " in repr(type.__getattribute__(cls, 'instance')) + assert "<__main__.A(0x" in repr(cls.__dict__['instance']) + assert "<__main__.A(0x" in repr(cls.instance) + assert "<__main__.A(0x" in repr(type.__getattribute__(cls, 'instance')) if __name__ == "__main__": diff --git a/sources/pyside2/tests/QtCore/qcalendar_test.py b/sources/pyside2/tests/QtCore/qcalendar_test.py new file mode 100644 index 000000000..4b595a011 --- /dev/null +++ b/sources/pyside2/tests/QtCore/qcalendar_test.py @@ -0,0 +1,47 @@ +#!/usr/bin/python + +############################################################################# +## +## Copyright (C) 2019 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$ +## +############################################################################# + +'''Test cases for QCalendar (5.14)''' + +import unittest + +from PySide2.QtCore import QCalendar + +class TestQCalendar (unittest.TestCase): + def testCalendar(self): + calendar = QCalendar(QCalendar.System.Gregorian) + self.assertTrue(calendar.isGregorian()) + self.assertEqual(calendar.name(), 'Gregorian') + self.assertFalse(calendar.hasYearZero()) + self.assertEqual(calendar.monthsInYear(2019), 12) + + +if __name__ == '__main__': + unittest.main() diff --git a/sources/pyside2/tests/QtCore/qsettings_test.py b/sources/pyside2/tests/QtCore/qsettings_test.py index 6d64b0db3..36a4c3c62 100644 --- a/sources/pyside2/tests/QtCore/qsettings_test.py +++ b/sources/pyside2/tests/QtCore/qsettings_test.py @@ -55,15 +55,55 @@ class TestQSettings(unittest.TestCase): def testDefaultValueConversion(self): settings = QSettings('foo.ini', QSettings.IniFormat) - r = settings.value('lala', 22) + settings.setValue('zero_value', 0) + settings.setValue('empty_list', []) + settings.setValue('bool1', False) + settings.setValue('bool2', True) + del settings + + # Loading values already set + settings = QSettings('foo.ini', QSettings.IniFormat) + + # Getting value that doesn't exist + r = settings.value("variable") + self.assertEqual(type(r), type(None)) + + # Handling zero value + r = settings.value('zero_value') if py3k.IS_PY3K: self.assertEqual(type(r), int) else: self.assertEqual(type(r), long) - r = settings.value('lala', 22, type=str) - self.assertEqual(type(r), str) + r = settings.value('zero_value', type=int) + self.assertEqual(type(r), int) + + # Empty list + r = settings.value('empty_list') + self.assertTrue(len(r) == 0) + self.assertEqual(type(r), list) + + r = settings.value('empty_list', type=list) + self.assertTrue(len(r) == 0) + self.assertEqual(type(r), list) + + # Booleans + r = settings.value('bool1') + self.assertEqual(type(r), bool) + + r = settings.value('bool2') + self.assertEqual(type(r), bool) + + r = settings.value('bool1', type=bool) + self.assertEqual(type(r), bool) + + r = settings.value('bool2', type=int) + self.assertEqual(type(r), int) + + r = settings.value('bool2', type=bool) + self.assertEqual(type(r), bool) + # Not set variable, but with default value r = settings.value('lala', 22, type=bytes) self.assertEqual(type(r), bytes) |