diff options
| author | Christian Tismer <tismer@stackless.com> | 2020-10-27 11:34:32 +0100 |
|---|---|---|
| committer | Christian Tismer <tismer@stackless.com> | 2020-10-27 21:13:20 +0000 |
| commit | dcced0742f383b1932d0e56323387fbd8aeb4513 (patch) | |
| tree | ccafffb6ffb68c9b8ddbeb1ade1ac5c8a1efa59b /sources/pyside2/tests | |
| parent | 844f1cc2541fe7213ebf2d72039ef28a04e200b4 (diff) | |
remove traces of Python2 from Python code
It will be assumed that Python is always Python 3.
All checks for Python 2 are removed.
This is the first part of cleaning up the Python code.
We will then also clean the C code.
Task-number: PYSIDE-904
Change-Id: I06050a8c1a18a19583f551b61775833a91673f4e
Reviewed-by: Cristian Maureira-Fredes <cristian.maureira-fredes@qt.io>
Diffstat (limited to 'sources/pyside2/tests')
8 files changed, 8 insertions, 31 deletions
diff --git a/sources/pyside2/tests/QtCore/classinfo_test.py b/sources/pyside2/tests/QtCore/classinfo_test.py index 634e8f350..d517b19c7 100644 --- a/sources/pyside2/tests/QtCore/classinfo_test.py +++ b/sources/pyside2/tests/QtCore/classinfo_test.py @@ -108,9 +108,4 @@ class TestClassInfo(unittest.TestCase): ClassInfo()(SubclassOfPythonQObjectSubclass) if __name__ == '__main__': - if sys.version_info[0] < 2: - sys.exit(0) - elif (sys.version_info[0] == 2) and (sys.version_info[1] <= 5): - sys.exit(0) - else: - unittest.main() + unittest.main() diff --git a/sources/pyside2/tests/QtCore/duck_punching_test.py b/sources/pyside2/tests/QtCore/duck_punching_test.py index 3450314dd..a735ecfa6 100644 --- a/sources/pyside2/tests/QtCore/duck_punching_test.py +++ b/sources/pyside2/tests/QtCore/duck_punching_test.py @@ -43,10 +43,7 @@ from PySide2.QtCore import QObject from helper.usesqcoreapplication import UsesQCoreApplication def MethodType(func, instance, instanceType): - if sys.version_info[0] == 3: - return types.MethodType(func, instance) - else: - return types.MethodType(func, instance, instanceType) + return types.MethodType(func, instance) class Duck(QObject): def __init__(self): diff --git a/sources/pyside2/tests/QtCore/qenum_test.py b/sources/pyside2/tests/QtCore/qenum_test.py index f99a893d9..f664087fd 100644 --- a/sources/pyside2/tests/QtCore/qenum_test.py +++ b/sources/pyside2/tests/QtCore/qenum_test.py @@ -137,11 +137,7 @@ class TestEnumPickling(unittest.TestCase): # Note: For Python 2, we would need quite strange patches. func = lambda: pickle.loads(pickle.dumps(Qt.Key)) - if sys.version_info[0] < 3: - with self.assertRaises(pickle.PicklingError): - func() - else: - func() + func() # PYSIDE-957: The QEnum macro diff --git a/sources/pyside2/tests/QtCore/qfile_test.py b/sources/pyside2/tests/QtCore/qfile_test.py index 57f9f4ee8..4617b1b2a 100644 --- a/sources/pyside2/tests/QtCore/qfile_test.py +++ b/sources/pyside2/tests/QtCore/qfile_test.py @@ -66,10 +66,7 @@ class GetCharTest(unittest.TestCase): try: memory = obj.map(0, 1) self.assertEqual(len(memory), 1) - if sys.version_info[0] >= 3: - self.assertEqual(memory[0], ord('a')) - else: - self.assertEqual(memory[0], bytes('a', "UTF-8")) + self.assertEqual(memory[0], ord('a')) # now memory points to wild bytes... :-) # uncommenting this must cause a segfault. # self.assertEqual(memory[0], 'a') diff --git a/sources/pyside2/tests/QtWidgets/qwidget_test.py b/sources/pyside2/tests/QtWidgets/qwidget_test.py index 5e94a8248..e2f7e5ed1 100644 --- a/sources/pyside2/tests/QtWidgets/qwidget_test.py +++ b/sources/pyside2/tests/QtWidgets/qwidget_test.py @@ -58,13 +58,6 @@ class QWidgetTest(UsesQApplication): def testInheritance(self): self.assertRaises(TypeError, QWidgetInherit) - if sys.version_info[0] < 3: - def testCallType_Issue_816(self): - thing = type(QWidget).__new__(type(QWidget), "", (), {}) - # PYSIDE-1286: This works now like in Python 3 - #self.assertEqual(repr(thing), "<class '__main__.'>") - self.assertEqual(repr(thing), "<class '__main__.ObjectType'>") - class QWidgetVisible(UsesQApplication): def testBasic(self): diff --git a/sources/pyside2/tests/pysidetest/new_inherited_functions_test.py b/sources/pyside2/tests/pysidetest/new_inherited_functions_test.py index 55953ad69..1998376d7 100644 --- a/sources/pyside2/tests/pysidetest/new_inherited_functions_test.py +++ b/sources/pyside2/tests/pysidetest/new_inherited_functions_test.py @@ -144,7 +144,7 @@ class MainTest(unittest.TestCase): #qPaintDevice = PySide2.QtGui.QPaintDevice() # NotImplementedError qTextDocument = PySide2.QtGui.QTextDocument() qTextFormat = PySide2.QtGui.QTextFormat() - quintptr = long(42) if sys.version_info[0] < 3 else 42 + quintptr = 42 qFont = PySide2.QtGui.QFont() qPalette = PySide2.QtGui.QPalette() except AttributeError: diff --git a/sources/pyside2/tests/pysidetest/property_python_test.py b/sources/pyside2/tests/pysidetest/property_python_test.py index 7df104525..443977c90 100644 --- a/sources/pyside2/tests/pysidetest/property_python_test.py +++ b/sources/pyside2/tests/pysidetest/property_python_test.py @@ -55,9 +55,8 @@ import sys import unittest has_test = False try: - if sys.version_info[0] >= 3: # This test has no support in Python 2 - from test import support - has_test = True + from test import support + has_test = True except ImportError: pass diff --git a/sources/pyside2/tests/registry/util.py b/sources/pyside2/tests/registry/util.py index 2a5ec322a..612ed253f 100644 --- a/sources/pyside2/tests/registry/util.py +++ b/sources/pyside2/tests/registry/util.py @@ -112,7 +112,7 @@ def linux_distribution(): distribution = distro.linux_distribution() except ImportError: # platform.linux_distribution() was removed in 3.8 - if sys.version_info[0] < 3 or sys.version_info[1] < 8: + if sys.version_info[:2] < (3, 8): import platform distribution = platform.linux_distribution() if distribution: |
