diff options
Diffstat (limited to 'sources/pyside6/tests')
| -rw-r--r-- | sources/pyside6/tests/QtCore/emoji_string_test.py | 5 | ||||
| -rw-r--r-- | sources/pyside6/tests/QtCore/qcbor_test.py | 18 | ||||
| -rw-r--r-- | sources/pyside6/tests/QtCore/qenum_test.py | 23 | ||||
| -rw-r--r-- | sources/pyside6/tests/pysidetest/new_inherited_functions_test.py | 73 | ||||
| -rw-r--r-- | sources/pyside6/tests/pysidetest/property_python_test.py | 5 | ||||
| -rw-r--r-- | sources/pyside6/tests/registry/init_platform.py | 5 | ||||
| -rw-r--r-- | sources/pyside6/tests/registry/util.py | 1 |
7 files changed, 58 insertions, 72 deletions
diff --git a/sources/pyside6/tests/QtCore/emoji_string_test.py b/sources/pyside6/tests/QtCore/emoji_string_test.py index 6b4db7d99..e8d4864dd 100644 --- a/sources/pyside6/tests/QtCore/emoji_string_test.py +++ b/sources/pyside6/tests/QtCore/emoji_string_test.py @@ -41,10 +41,7 @@ class TestStuff(QObject): self.testsig.emit(emoji_str) def plausi(self): - # Python 2 may be built with UCS-2 or UCS-4 support. - # UCS-2 creates 2 surrogate code points. See - # https://stackoverflow.com/questions/30775689/python-length-of-unicode-string-confusion - assert len(emoji_str) == 2 if sys.maxunicode > 0xffff else 3 + assert len(emoji_str) == 2 if __name__ == "__main__": diff --git a/sources/pyside6/tests/QtCore/qcbor_test.py b/sources/pyside6/tests/QtCore/qcbor_test.py index 8d49c7151..67c23dc5d 100644 --- a/sources/pyside6/tests/QtCore/qcbor_test.py +++ b/sources/pyside6/tests/QtCore/qcbor_test.py @@ -15,8 +15,7 @@ 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 (QByteArray, QCborStreamReader, QCborStreamWriter, - QCborTag, QCborValue) +from PySide6.QtCore import QByteArray, QCborStreamReader, QCborStreamWriter, QCborValue class TestCbor(unittest.TestCase): @@ -33,7 +32,7 @@ class TestCbor(unittest.TestCase): value = reader.toInteger() self.assertEqual(value, 42) - def testReader(self): + def anotherTestReader(self): ba = QByteArray() writer = QCborStreamWriter(ba) writer.append("hello") @@ -43,15 +42,10 @@ class TestCbor(unittest.TestCase): self.assertTrue(not ba.isEmpty()) reader = QCborStreamReader(ba) self.assertTrue(reader.hasNext()) - if (reader.isByteArray()): # Python 2 - value = reader.readByteArray() - self.assertTrue(value) - self.assertEqual(value.data, "hello") - else: - self.assertTrue(reader.isString()) - value = reader.readString() - self.assertTrue(value) - self.assertEqual(value.data, "hello") + self.assertTrue(reader.isString()) + value = reader.readString() + self.assertTrue(value) + self.assertEqual(value.data, "hello") def testValue(self): value = QCborValue('hello') diff --git a/sources/pyside6/tests/QtCore/qenum_test.py b/sources/pyside6/tests/QtCore/qenum_test.py index e064ea40d..c3122276f 100644 --- a/sources/pyside6/tests/QtCore/qenum_test.py +++ b/sources/pyside6/tests/QtCore/qenum_test.py @@ -33,8 +33,8 @@ class TestEnum(unittest.TestCase): def testEnumNew_NoLeak(self): gc.collect() total = sys.gettotalrefcount() - for idx in range(1000): - ret = Qt.Key(42) + for _ in range(1000): + ret = Qt.Key(42) # noqa: F841 gc.collect() delta = sys.gettotalrefcount() - total @@ -65,9 +65,9 @@ class TestQFlags(unittest.TestCase): def testNonExtensibleEnums(self): try: - om = QIODevice.OpenMode(QIODevice.WriteOnly) + om = QIODevice.OpenMode(QIODevice.WriteOnly) # noqa: F841 self.assertFail() - except: + except: # noqa: E722 pass @@ -88,9 +88,7 @@ class TestEnumPickling(unittest.TestCase): # This works also with nested classes for Python 3, after we # introduced the correct __qualname__ attribute. - - # Note: For Python 2, we would need quite strange patches. - func = lambda: pickle.loads(pickle.dumps(Qt.Key)) + func = lambda: pickle.loads(pickle.dumps(Qt.Key)) # noqa: E731 func() # PYSIDE-957: The QEnum macro @@ -101,7 +99,7 @@ try: HAVE_ENUM = True except ImportError: HAVE_ENUM = False - QEnum = QFlag = lambda x: x + QEnum = QFlag = lambda x: x # noqa: F811 import types class Enum: @@ -144,7 +142,7 @@ class SomeClass(QObject): class InnerEnum(enum.Enum): X = 42 - class SomeEnum(enum.Enum): + class SomeEnum(enum.Enum): # noqa: F811 A = 4 B = 5 C = 6 @@ -166,10 +164,9 @@ class TestQEnumMacro(unittest.TestCase): int(SomeClass.SomeEnum.C) == 6 self.assertEqual(SomeClass.OtherEnum.C, 3) - @unittest.skipIf(sys.version_info[0] < 3, "we cannot support nested classes in Python 2") def testInnerClass(self): self.assertEqual(SomeClass.InnerClass.InnerEnum.__qualname__, - "SomeClass.InnerClass.InnerEnum") + "SomeClass.InnerClass.InnerEnum") with self.assertRaises(TypeError): int(SomeClass.InnerClass.InnerEnum.X) == 42 @@ -194,8 +191,8 @@ class TestQEnumMacro(unittest.TestCase): self.assertEqual(mo.enumerator(1).name(), "SomeEnum") moi = SomeClass.InnerClass.staticMetaObject self.assertEqual(moi.enumerator(0).name(), "InnerEnum") - ## Question: Should that scope not better be "SomeClass.InnerClass"? - ## But we have __qualname__ already: + # Question: Should that scope not better be "SomeClass.InnerClass"? + # But we have __qualname__ already: self.assertEqual(moi.enumerator(0).scope(), "InnerClass") diff --git a/sources/pyside6/tests/pysidetest/new_inherited_functions_test.py b/sources/pyside6/tests/pysidetest/new_inherited_functions_test.py index e474e5d39..10ac2c373 100644 --- a/sources/pyside6/tests/pysidetest/new_inherited_functions_test.py +++ b/sources/pyside6/tests/pysidetest/new_inherited_functions_test.py @@ -11,14 +11,18 @@ sys.path.append(os.fspath(Path(__file__).resolve().parents[1])) from init_paths import init_test_paths init_test_paths(False) -from PySide6 import * +from PySide6 import * # noqa: F401,F403 from PySide6.support.signature import get_signature for modname, mod in sys.modules.items(): - # Python 2 leaves "None" in the dict. - if modname.startswith("PySide6.") and mod is not None: + if modname.startswith("PySide6."): print("importing", modname) exec("import " + modname) +# To help linters +import PySide6.QtCore +import PySide6.QtGui +import PySide6.QtWidgets + # This test tests the existence and callability of the newly existing functions, # after the inheritance was made complete in the course of PYSIDE-331. @@ -33,7 +37,7 @@ new_functions = """ """ new_functions += """ - PySide6.QtGui.QStandardItemModel().insertColumn(int,qModelIndex) + PySide6.QtGui.QStandardItemModel().insertColumn(_int,qModelIndex) PySide6.QtGui.QStandardItemModel().parent() # PySide6.QtGui.QTextList(qTextDocument).setFormat(qTextFormat) # Segmentation fault: 11 # PySide6.QtGui.QTextTable(qTextDocument).setFormat(qTextFormat) # Segmentation fault: 11 @@ -47,13 +51,13 @@ new_functions += """ PySide6.QtWidgets.QBoxLayout(direction).addWidget(qWidget) PySide6.QtWidgets.QColorDialog().open() PySide6.QtWidgets.QFileDialog().open() - PySide6.QtWidgets.QFileSystemModel().index(int,int,qModelIndex) + PySide6.QtWidgets.QFileSystemModel().index(_int,_int,qModelIndex) PySide6.QtWidgets.QFileSystemModel().parent() PySide6.QtWidgets.QFontDialog().open() PySide6.QtWidgets.QGestureEvent([]).accept() PySide6.QtWidgets.QGestureEvent([]).ignore() PySide6.QtWidgets.QGestureEvent([]).isAccepted() - PySide6.QtWidgets.QGestureEvent([]).setAccepted(bool) + PySide6.QtWidgets.QGestureEvent([]).setAccepted(_bool) # PySide6.QtWidgets.QGraphicsView().render(qPaintDevice,qPoint,qRegion,renderFlags) # QPaintDevice: NotImplementedError PySide6.QtWidgets.QGridLayout().addWidget(qWidget) PySide6.QtWidgets.QInputDialog().open() @@ -76,8 +80,8 @@ new_functions += """ new_functions += """ PySide6.QtHelp.QHelpContentModel().parent() - # PySide6.QtHelp.QHelpIndexModel().createIndex(int,int,quintptr) # returned NULL without setting an error - # PySide6.QtHelp.QHelpIndexModel().createIndex(int,int,object()) # returned NULL without setting an error + # PySide6.QtHelp.QHelpIndexModel().createIndex(_int,_int,quintptr) # returned NULL without setting an error + # PySide6.QtHelp.QHelpIndexModel().createIndex(_int,_int,object()) # returned NULL without setting an error """ if "PySide6.QtHelp" in sys.modules else "" new_functions += """ @@ -97,34 +101,34 @@ class MainTest(unittest.TestCase): break except AttributeError: continue - bool = True - int = 42 - qint64 = 42 - tfarg = os.path.join(PySide6.QtCore.QDir.tempPath(), "XXXXXX.tmp") - findStr = 'bla' - orientation = PySide6.QtCore.Qt.Orientations() - openMode = PySide6.QtCore.QIODevice.OpenMode(PySide6.QtCore.QIODevice.ReadOnly) - qModelIndex = PySide6.QtCore.QModelIndex() - transformationMode = PySide6.QtCore.Qt.TransformationMode() - qObject = PySide6.QtCore.QObject() - qPoint = PySide6.QtCore.QPoint() + _bool = True # noqa: F841,F405 + _int = 42 # noqa: F841,F405 + qint64 = 42 # noqa: F841,F405 + tfarg = os.path.join(PySide6.QtCore.QDir.tempPath(), "XXXXXX.tmp") # noqa: F841,F405 + findStr = 'bla' # noqa: F841,F405 + orientation = PySide6.QtCore.Qt.Orientations() # noqa: F841,F405 + openMode = PySide6.QtCore.QIODevice.OpenMode(PySide6.QtCore.QIODevice.ReadOnly) # noqa: F841,F405 + qModelIndex = PySide6.QtCore.QModelIndex() # noqa: F841,F405 + transformationMode = PySide6.QtCore.Qt.TransformationMode() # noqa: F841,F405 + qObject = PySide6.QtCore.QObject() # noqa: F841,F405 + qPoint = PySide6.QtCore.QPoint() # noqa: F841,F405 try: - PySide6.QtGui + PySide6.QtGui # noqa: F405 #qPaintDevice = PySide6.QtGui.QPaintDevice() # NotImplementedError - qTextDocument = PySide6.QtGui.QTextDocument() - qTextFormat = PySide6.QtGui.QTextFormat() - quintptr = 42 - qFont = PySide6.QtGui.QFont() - qPalette = PySide6.QtGui.QPalette() + qTextDocument = PySide6.QtGui.QTextDocument() # noqa: F841,F405 + qTextFormat = PySide6.QtGui.QTextFormat() # noqa: F841,F405 + quintptr = 42 # noqa: F841,F405 + qFont = PySide6.QtGui.QFont() # noqa: F841,F405 + qPalette = PySide6.QtGui.QPalette() # noqa: F841,F405 except AttributeError: pass try: - PySide6.QtWidgets - direction = PySide6.QtWidgets.QBoxLayout.Direction() - qWidget = PySide6.QtWidgets.QWidget() - qStyleOptionFrame = PySide6.QtWidgets.QStyleOptionFrame() - qAction = PySide6.QtGui.QAction(qObject) - renderFlags = PySide6.QtWidgets.QWidget.RenderFlags + PySide6.QtWidgets # noqa: F405 + direction = PySide6.QtWidgets.QBoxLayout.Direction() # noqa: F841,F405 + qWidget = PySide6.QtWidgets.QWidget() # noqa: F841,F405 + qStyleOptionFrame = PySide6.QtWidgets.QStyleOptionFrame() # noqa: F841,F405 + qAction = PySide6.QtGui.QAction(qObject) # noqa: F841,F405 + renderFlags = PySide6.QtWidgets.QWidget.RenderFlags # noqa: F841,F405 except AttributeError: pass @@ -147,12 +151,13 @@ class MainTest(unittest.TestCase): palette() without argument. """ try: - qApp = (PySide6.QtWidgets.QApplication.instance() or - PySide6.QtWidgets.QApplication([])) + qApp = ( # noqa: F841 + PySide6.QtWidgets.QApplication.instance() or PySide6.QtWidgets.QApplication([]) # noqa: F405 + ) except AttributeError: unittest.TestCase().skipTest("this test makes only sense if QtWidgets is available.") - sigs = get_signature(PySide6.QtWidgets.QApplication.palette) + sigs = get_signature(PySide6.QtWidgets.QApplication.palette) # noqa: F405 self.assertEqual(len(sigs), 3) diff --git a/sources/pyside6/tests/pysidetest/property_python_test.py b/sources/pyside6/tests/pysidetest/property_python_test.py index 31c1f40c7..e26f07bb9 100644 --- a/sources/pyside6/tests/pysidetest/property_python_test.py +++ b/sources/pyside6/tests/pysidetest/property_python_test.py @@ -27,9 +27,6 @@ init_test_paths(False) from PySide6.QtCore import Property, QObject -# This are the original imports. -import sys -import unittest has_test = False try: from test import support @@ -203,7 +200,7 @@ class PropertyTests(unittest.TestCase): sub.__class__.spam.__doc__ = 'Spam' self.assertEqual(sub.__class__.spam.__doc__, 'Spam') - if has_test: # This test has no support in Python 2 + if has_test: @support.refcount_test def test_refleaks_in___init__(self): gettotalrefcount = support.get_attribute(sys, 'gettotalrefcount') diff --git a/sources/pyside6/tests/registry/init_platform.py b/sources/pyside6/tests/registry/init_platform.py index 93fa64dec..0a040d0fc 100644 --- a/sources/pyside6/tests/registry/init_platform.py +++ b/sources/pyside6/tests/registry/init_platform.py @@ -189,10 +189,7 @@ def generate_all(): {build} There are no default values, no variable names and no self - parameter. Only types are present after simplification. The - functions 'next' resp. '__next__' are removed to make the output - identical for Python 2 and 3. '__div__' is also removed, - since it exists in Python 2, only. + parameter. Only types are present after simplification. """ ''')) fmt.print("import sys") diff --git a/sources/pyside6/tests/registry/util.py b/sources/pyside6/tests/registry/util.py index 97978f310..fc0026fa3 100644 --- a/sources/pyside6/tests/registry/util.py +++ b/sources/pyside6/tests/registry/util.py @@ -48,7 +48,6 @@ def check_warnings(): if mod: reg = getattr(mod, warn_name, None) if reg: - # XXX We need to filter warnings for Python 2. # This should be avoided by renaming the duplicate folders. for k in reg: if type(k) is tuple and re.match(ignore_re, k[0]): |
