aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorFriedemann Kleint <Friedemann.Kleint@qt.io>2021-04-27 08:22:07 +0200
committerFriedemann Kleint <Friedemann.Kleint@qt.io>2021-04-27 15:30:14 +0200
commit70ffe0b5136cfce75c94fa09cd6070b7270f684d (patch)
tree4b22b5d9d7b055340a723d41e2f88fcac212f143
parent8245dd6356dbb0124a7477b16f19e5f031074f85 (diff)
Tests: Use per-class imports
Change-Id: I6dac1f54152fecab7af6831bc3c813a016408aae Reviewed-by: Christian Tismer <tismer@stackless.com>
-rw-r--r--sources/pyside6/tests/QtCore/bug_1063.py10
-rw-r--r--sources/pyside6/tests/QtCore/bug_1069.py6
-rw-r--r--sources/pyside6/tests/QtCore/bug_1313.py6
-rw-r--r--sources/pyside6/tests/QtCore/bug_278_test.py5
-rw-r--r--sources/pyside6/tests/QtCore/bug_332.py7
-rw-r--r--sources/pyside6/tests/QtCore/bug_515.py9
-rw-r--r--sources/pyside6/tests/QtCore/emoji_string_test.py7
-rw-r--r--sources/pyside6/tests/QtCore/errormessages_with_features_test.py16
-rw-r--r--sources/pyside6/tests/QtCore/multiple_feature_test.py32
-rw-r--r--sources/pyside6/tests/QtCore/qabs_test.py6
-rw-r--r--sources/pyside6/tests/QtCore/qobject_destructor.py9
-rw-r--r--sources/pyside6/tests/QtCore/qslot_object_test.py17
-rw-r--r--sources/pyside6/tests/QtCore/snake_prop_feature_test.py18
-rw-r--r--sources/pyside6/tests/QtGui/bug_1091.py7
-rw-r--r--sources/pyside6/tests/QtGui/bug_367.py7
-rw-r--r--sources/pyside6/tests/QtGui/bug_480.py14
-rw-r--r--sources/pyside6/tests/QtNetwork/bug_1084.py4
-rw-r--r--sources/pyside6/tests/QtQml/bug_451.py21
-rw-r--r--sources/pyside6/tests/QtQml/bug_456.py17
-rw-r--r--sources/pyside6/tests/QtQml/bug_726.py17
-rw-r--r--sources/pyside6/tests/QtQml/bug_997.py12
-rw-r--r--sources/pyside6/tests/QtQml/connect_python_qml.py12
-rw-r--r--sources/pyside6/tests/QtQml/qquickitem_grabToImage.py16
-rw-r--r--sources/pyside6/tests/QtUiTools/bug_360.py8
-rw-r--r--sources/pyside6/tests/QtUiTools/bug_376.py7
-rw-r--r--sources/pyside6/tests/QtUiTools/bug_552.py12
-rw-r--r--sources/pyside6/tests/QtUiTools/bug_797.py14
-rw-r--r--sources/pyside6/tests/QtUiTools/bug_958.py8
-rw-r--r--sources/pyside6/tests/QtWidgets/bug_1048.py9
-rw-r--r--sources/pyside6/tests/QtWidgets/bug_1077.py11
-rw-r--r--sources/pyside6/tests/QtWidgets/bug_338.py9
-rw-r--r--sources/pyside6/tests/QtWidgets/bug_389.py10
-rw-r--r--sources/pyside6/tests/QtWidgets/bug_433.py12
-rw-r--r--sources/pyside6/tests/QtWidgets/bug_547.py13
-rw-r--r--sources/pyside6/tests/QtWidgets/bug_576.py14
-rw-r--r--sources/pyside6/tests/QtWidgets/bug_585.py11
-rw-r--r--sources/pyside6/tests/QtWidgets/bug_589.py10
-rw-r--r--sources/pyside6/tests/QtWidgets/bug_834.py18
-rw-r--r--sources/pyside6/tests/QtWidgets/bug_921.py17
-rw-r--r--sources/pyside6/tests/QtWidgets/python_properties_test.py10
-rw-r--r--sources/pyside6/tests/QtWidgets/qapp_issue_585.py5
-rw-r--r--sources/pyside6/tests/QtWidgets/qfontdialog_test.py13
-rw-r--r--sources/pyside6/tests/QtWidgets/qgraphicsitem_isblocked_test.py15
-rw-r--r--sources/pyside6/tests/QtWidgets/qinputdialog_get_test.py11
-rw-r--r--sources/pyside6/tests/QtWidgets/qlistwidget_test.py24
-rw-r--r--sources/pyside6/tests/QtWidgets/qlistwidgetitem_test.py10
-rw-r--r--sources/pyside6/tests/QtWidgets/qmainwindow_test.py30
-rw-r--r--sources/pyside6/tests/QtWidgets/qmenuadd_test.py6
-rw-r--r--sources/pyside6/tests/QtWidgets/qtextedit_signal_test.py13
-rw-r--r--sources/pyside6/tests/QtWidgets/qtreewidgetitem_test.py13
-rw-r--r--sources/pyside6/tests/QtWidgets/wrong_return_test.py4
-rw-r--r--sources/pyside6/tests/pysidetest/mixin_signal_slots_test.py29
-rw-r--r--sources/pyside6/tests/pysidetest/signal_tp_descr_get_test.py6
-rw-r--r--sources/pyside6/tests/pysidetest/version_test.py7
-rw-r--r--sources/pyside6/tests/signals/bug_189.py8
-rw-r--r--sources/pyside6/tests/signals/bug_311.py12
-rw-r--r--sources/pyside6/tests/signals/bug_319.py13
-rw-r--r--sources/pyside6/tests/signals/bug_79.py10
-rw-r--r--sources/pyside6/tests/signals/leaking_signal_test.py6
-rw-r--r--sources/pyside6/tests/signals/signal_number_limit_test.py33
60 files changed, 396 insertions, 340 deletions
diff --git a/sources/pyside6/tests/QtCore/bug_1063.py b/sources/pyside6/tests/QtCore/bug_1063.py
index 8ccd9a593..c92f4f191 100644
--- a/sources/pyside6/tests/QtCore/bug_1063.py
+++ b/sources/pyside6/tests/QtCore/bug_1063.py
@@ -38,17 +38,17 @@ sys.path.append(os.fspath(Path(__file__).resolve().parents[1]))
from init_paths import init_test_paths
init_test_paths(False)
-from PySide6 import QtCore
+from PySide6.QtCore import QFile, QIODevice, QTextStream
class QTextStreamTestCase(unittest.TestCase):
def setUp(self):
self.temp_file = tempfile.NamedTemporaryFile(delete=False)
self.temp_file.close()
- self.f = QtCore.QFile(self.temp_file.name)
- self.f.open(QtCore.QIODevice.WriteOnly)
+ self.f = QFile(self.temp_file.name)
+ self.f.open(QIODevice.WriteOnly)
self.strings = ('foo', 'bar')
- self.stream = QtCore.QTextStream(self.f)
+ self.stream = QTextStream(self.f)
def testIt(self):
for s in self.strings:
@@ -57,7 +57,7 @@ class QTextStreamTestCase(unittest.TestCase):
self.f.close()
# make sure we didn't get an empty file
- self.assertNotEqual(QtCore.QFile(self.temp_file.name).size(), 0)
+ self.assertNotEqual(QFile(self.temp_file.name).size(), 0)
os.unlink(self.temp_file.name)
diff --git a/sources/pyside6/tests/QtCore/bug_1069.py b/sources/pyside6/tests/QtCore/bug_1069.py
index a62ff5530..505ebdb8f 100644
--- a/sources/pyside6/tests/QtCore/bug_1069.py
+++ b/sources/pyside6/tests/QtCore/bug_1069.py
@@ -37,13 +37,13 @@ sys.path.append(os.fspath(Path(__file__).resolve().parents[1]))
from init_paths import init_test_paths
init_test_paths(False)
-from PySide6 import QtCore
+from PySide6.QtCore import QByteArray, QDataStream, QIODevice
class QDataStreamOpOverloadTestCase(unittest.TestCase):
def setUp(self):
- self.ba = QtCore.QByteArray()
- self.stream = QtCore.QDataStream(self.ba, QtCore.QIODevice.WriteOnly)
+ self.ba = QByteArray()
+ self.stream = QDataStream(self.ba, QIODevice.WriteOnly)
def testIt(self):
self.stream << "hello"
diff --git a/sources/pyside6/tests/QtCore/bug_1313.py b/sources/pyside6/tests/QtCore/bug_1313.py
index 01a76f5c9..a80c81cc8 100644
--- a/sources/pyside6/tests/QtCore/bug_1313.py
+++ b/sources/pyside6/tests/QtCore/bug_1313.py
@@ -37,11 +37,11 @@ sys.path.append(os.fspath(Path(__file__).resolve().parents[1]))
from init_paths import init_test_paths
init_test_paths(False)
-from PySide6 import QtCore
+from PySide6.QtCore import QObject, Signal
-class MyQObject(QtCore.QObject):
- sig = QtCore.Signal()
+class MyQObject(QObject):
+ sig = Signal()
demo_coroutine_definition_code = """
diff --git a/sources/pyside6/tests/QtCore/bug_278_test.py b/sources/pyside6/tests/QtCore/bug_278_test.py
index aadaaf4d9..f4ce190b8 100644
--- a/sources/pyside6/tests/QtCore/bug_278_test.py
+++ b/sources/pyside6/tests/QtCore/bug_278_test.py
@@ -37,7 +37,8 @@ sys.path.append(os.fspath(Path(__file__).resolve().parents[1]))
from init_paths import init_test_paths
init_test_paths(False)
-from PySide6 import QtCore
+from PySide6.QtCore import QObject
+
def setValue(o):
values = ['Name']
@@ -47,7 +48,7 @@ class QQtVersionTest(unittest.TestCase):
'''Tests for QVariant conversion of QStringList'''
def testGet(self):
- o = QtCore.QObject()
+ o = QObject()
setValue(o)
self.assertEqual(o.property('test1'), ['Name'])
diff --git a/sources/pyside6/tests/QtCore/bug_332.py b/sources/pyside6/tests/QtCore/bug_332.py
index 7d7be4d05..6b2e62db8 100644
--- a/sources/pyside6/tests/QtCore/bug_332.py
+++ b/sources/pyside6/tests/QtCore/bug_332.py
@@ -37,11 +37,12 @@ sys.path.append(os.fspath(Path(__file__).resolve().parents[1]))
from init_paths import init_test_paths
init_test_paths(False)
-from PySide6 import QtCore
+from PySide6.QtCore import QMutex
-class Lock(QtCore.QMutex):
+
+class Lock(QMutex):
def tryLock(self,timeoutt=10):
- return QtCore.QMutex.tryLock(self,timeoutt)
+ return QMutex.tryLock(self,timeoutt)
class TestBug(unittest.TestCase):
diff --git a/sources/pyside6/tests/QtCore/bug_515.py b/sources/pyside6/tests/QtCore/bug_515.py
index 5a5264486..917357f88 100644
--- a/sources/pyside6/tests/QtCore/bug_515.py
+++ b/sources/pyside6/tests/QtCore/bug_515.py
@@ -38,7 +38,8 @@ sys.path.append(os.fspath(Path(__file__).resolve().parents[1] / "util"))
from init_paths import init_test_paths
init_test_paths()
-from PySide6 import QtCore
+from PySide6.QtCore import QCoreApplication, qAddPostRoutine
+
callCleanup = False
def _cleanup():
@@ -49,7 +50,7 @@ def _checkCleanup():
global callCleanup
assert(callCleanup)
-app = QtCore.QCoreApplication([])
-QtCore.qAddPostRoutine(_cleanup)
-QtCore.qAddPostRoutine(_checkCleanup)
+app = QCoreApplication([])
+qAddPostRoutine(_cleanup)
+qAddPostRoutine(_checkCleanup)
del app
diff --git a/sources/pyside6/tests/QtCore/emoji_string_test.py b/sources/pyside6/tests/QtCore/emoji_string_test.py
index 553864088..f575a7b77 100644
--- a/sources/pyside6/tests/QtCore/emoji_string_test.py
+++ b/sources/pyside6/tests/QtCore/emoji_string_test.py
@@ -59,12 +59,13 @@ sys.path.append(os.fspath(Path(__file__).resolve().parents[1] / "util"))
from init_paths import init_test_paths
init_test_paths()
-from PySide6 import QtCore
+from PySide6.QtCore import QObject, Signal
+
emoji_str = u'\U0001f632' + u' ' # "😲 "
-class TestStuff(QtCore.QObject):
- testsig = QtCore.Signal(str)
+class TestStuff(QObject):
+ testsig = Signal(str)
def a_nop(self, sendMeAnEmoji):
print(sendMeAnEmoji)
diff --git a/sources/pyside6/tests/QtCore/errormessages_with_features_test.py b/sources/pyside6/tests/QtCore/errormessages_with_features_test.py
index bbad67a77..05670373f 100644
--- a/sources/pyside6/tests/QtCore/errormessages_with_features_test.py
+++ b/sources/pyside6/tests/QtCore/errormessages_with_features_test.py
@@ -46,7 +46,7 @@ sys.path.append(os.fspath(Path(__file__).resolve().parents[1]))
from init_paths import init_test_paths
init_test_paths(False)
-from PySide6 import QtWidgets
+from PySide6.QtWidgets import QApplication, QLabel
from PySide6.support import __feature__
"""
@@ -65,7 +65,7 @@ class ErrormessagesWithFeatures(unittest.TestCase):
probe_miss = "missing signature"
def setUp(self):
- qApp or QtWidgets.QApplication()
+ qApp or QApplication()
__feature__.set_selection(0)
def tearDown(self):
@@ -74,35 +74,35 @@ class ErrormessagesWithFeatures(unittest.TestCase):
def testCorrectErrorMessagesPlain(self):
with self.assertRaises(TypeError) as cm:
- QtWidgets.QLabel().setFont(42)
+ QLabel().setFont(42)
print("\n\n" + cm.exception.args[0])
self.assertTrue(self.probe in cm.exception.args[0])
def testCorrectErrorMessagesSnake(self):
from __feature__ import snake_case
with self.assertRaises(TypeError) as cm:
- QtWidgets.QLabel().set_font(42)
+ QLabel().set_font(42)
print("\n\n" + cm.exception.args[0])
self.assertTrue(self.probe in cm.exception.args[0])
def testCorrectErrorMessagesProp(self):
from __feature__ import true_property
with self.assertRaises(TypeError) as cm:
- QtWidgets.QLabel().font = 42
+ QLabel().font = 42
print("\n\n" + cm.exception.args[0])
self.assertTrue(self.probe in cm.exception.args[0])
def testCorrectErrorMessagesSnakeProp(self):
from __feature__ import snake_case, true_property
with self.assertRaises(TypeError) as cm:
- QtWidgets.QLabel().font = 42
+ QLabel().font = 42
print("\n\n" + cm.exception.args[0])
self.assertTrue(self.probe in cm.exception.args[0])
def testCorrectErrorMessagesClassProp(self):
from __feature__ import true_property
with self.assertRaises(TypeError) as cm:
- QtWidgets.QApplication.quitOnLastWindowClosed = object
+ QApplication.quitOnLastWindowClosed = object
print("\n\n" + cm.exception.args[0])
self.assertTrue(self.probe_miss in cm.exception.args[0])
with self.assertRaises(TypeError) as cm:
@@ -112,7 +112,7 @@ class ErrormessagesWithFeatures(unittest.TestCase):
def testCorrectErrorMessagesClassSnakeProp(self):
from __feature__ import snake_case, true_property
with self.assertRaises(TypeError) as cm:
- QtWidgets.QApplication.quit_on_last_window_closed = object
+ QApplication.quit_on_last_window_closed = object
print("\n\n" + cm.exception.args[0])
self.assertTrue(self.probe_miss in cm.exception.args[0])
with self.assertRaises(TypeError) as cm:
diff --git a/sources/pyside6/tests/QtCore/multiple_feature_test.py b/sources/pyside6/tests/QtCore/multiple_feature_test.py
index 0f25e2f5c..8517bb70f 100644
--- a/sources/pyside6/tests/QtCore/multiple_feature_test.py
+++ b/sources/pyside6/tests/QtCore/multiple_feature_test.py
@@ -46,7 +46,7 @@ sys.path.append(os.fspath(Path(__file__).resolve().parents[1]))
from init_paths import init_test_paths
init_test_paths(False)
-from PySide6 import QtCore
+from PySide6.QtCore import QCborArray, QObject
from PySide6.support import __feature__
from textwrap import dedent
@@ -71,31 +71,31 @@ class FeaturesTest(unittest.TestCase):
def tst_bit0(flag, self, bits):
if flag == 0:
- QtCore.QCborArray.isEmpty
- QtCore.QCborArray.__dict__["isEmpty"]
+ QCborArray.isEmpty
+ QCborArray.__dict__["isEmpty"]
with self.assertRaises(AttributeError):
- QtCore.QCborArray.is_empty
+ QCborArray.is_empty
with self.assertRaises(KeyError):
- QtCore.QCborArray.__dict__["is_empty"]
+ QCborArray.__dict__["is_empty"]
else:
- QtCore.QCborArray.is_empty
- QtCore.QCborArray.__dict__["is_empty"]
+ QCborArray.is_empty
+ QCborArray.__dict__["is_empty"]
with self.assertRaises(AttributeError):
- QtCore.QCborArray.isEmpty
+ QCborArray.isEmpty
with self.assertRaises(KeyError):
- QtCore.QCborArray.__dict__["isEmpty"]
+ QCborArray.__dict__["isEmpty"]
def tst_bit1(flag, self, bits):
getter_name = "object_name" if bits & 1 else "objectName"
setter_name = "set_object_name" if bits & 1 else "setObjectName"
- thing = getattr(QtCore.QObject, getter_name)
+ thing = getattr(QObject, getter_name)
if flag:
self.assertEqual(type(thing), property)
with self.assertRaises(AttributeError):
- getattr(QtCore.QObject, setter_name)
+ getattr(QObject, setter_name)
else:
self.assertEqual(type(thing), MethodDescriptorType)
- getattr(QtCore.QObject, setter_name)
+ getattr(QObject, setter_name)
edict = {}
for bit in range(2, 8):
@@ -107,12 +107,12 @@ class FeaturesTest(unittest.TestCase):
def tst_bit{bit}(flag, self, bits):
if flag == 0:
with self.assertRaises(AttributeError):
- QtCore.QCborArray.fake_feature_{bit_pow:02x}
+ QCborArray.fake_feature_{bit_pow:02x}
with self.assertRaises(KeyError):
- QtCore.QCborArray.__dict__["fake_feature_{bit_pow:02x}"]
+ QCborArray.__dict__["fake_feature_{bit_pow:02x}"]
else:
- QtCore.QCborArray.fake_feature_{bit_pow:02x}
- QtCore.QCborArray.__dict__["fake_feature_{bit_pow:02x}"]
+ QCborArray.fake_feature_{bit_pow:02x}
+ QCborArray.__dict__["fake_feature_{bit_pow:02x}"]
"""), "<string>", "exec"), globals(), edict)
globals().update(edict)
diff --git a/sources/pyside6/tests/QtCore/qabs_test.py b/sources/pyside6/tests/QtCore/qabs_test.py
index a711ba9fb..5dbcd6061 100644
--- a/sources/pyside6/tests/QtCore/qabs_test.py
+++ b/sources/pyside6/tests/QtCore/qabs_test.py
@@ -35,15 +35,15 @@ sys.path.append(os.fspath(Path(__file__).resolve().parents[1]))
from init_paths import init_test_paths
init_test_paths(False)
-from PySide6 import QtCore
+from PySide6.QtCore import qAbs
class QAbsTest(unittest.TestCase):
- '''Tests for QtCore.qAbs'''
+ '''Tests for qAbs'''
def testBasic(self):
def check(x):
- self.assertEqual(QtCore.qAbs(x), abs(x))
+ self.assertEqual(qAbs(x), abs(x))
check(0)
check(-10)
diff --git a/sources/pyside6/tests/QtCore/qobject_destructor.py b/sources/pyside6/tests/QtCore/qobject_destructor.py
index 50f2ffc10..2354cdfa7 100644
--- a/sources/pyside6/tests/QtCore/qobject_destructor.py
+++ b/sources/pyside6/tests/QtCore/qobject_destructor.py
@@ -35,16 +35,17 @@ sys.path.append(os.fspath(Path(__file__).resolve().parents[1]))
from init_paths import init_test_paths
init_test_paths(False)
-from PySide6 import QtCore
+from PySide6.QtCore import QObject
-class MyObject(QtCore.QObject):
+
+class MyObject(QObject):
def __init__(self, other=None):
- QtCore.QObject.__init__(self, None)
+ super().__init__(None)
self._o = other
class TestDestructor(unittest.TestCase):
def testReference(self):
- o = QtCore.QObject()
+ o = QObject()
m = MyObject(o)
self.assertEqual(sys.getrefcount(o), 3)
del m
diff --git a/sources/pyside6/tests/QtCore/qslot_object_test.py b/sources/pyside6/tests/QtCore/qslot_object_test.py
index 56cd462ee..ebde10387 100644
--- a/sources/pyside6/tests/QtCore/qslot_object_test.py
+++ b/sources/pyside6/tests/QtCore/qslot_object_test.py
@@ -36,17 +36,18 @@ from pathlib import Path
sys.path.append(os.fspath(Path(__file__).resolve().parents[1]))
from init_paths import init_test_paths
init_test_paths(False)
-from PySide6 import QtCore
+
+from PySide6.QtCore import QCoreApplication, QObject, QTimer, SIGNAL, SLOT
"""
This is a simple slot test that was updated to use the qApp "macro".
It is implicitly in builtins and does not need an import.
"""
-class objTest(QtCore.QObject):
+class objTest(QObject):
def __init__(self, parent=None):
- QtCore.QObject.__init__(self, parent)
+ super().__init__(parent)
self.ok = False
@@ -60,20 +61,20 @@ class slotTest(unittest.TestCase):
qApp.quit()
def testBasic(self):
- timer = QtCore.QTimer()
+ timer = QTimer()
timer.setInterval(100)
my_obj = objTest()
- my_slot = QtCore.SLOT("slot()")
- QtCore.QObject.connect(timer, QtCore.SIGNAL("timeout()"), my_obj, my_slot)
+ my_slot = SLOT("slot()")
+ QObject.connect(timer, SIGNAL("timeout()"), my_obj, my_slot)
timer.start(100)
- QtCore.QTimer.singleShot(1000, self.quit_app)
+ QTimer.singleShot(1000, self.quit_app)
qApp.exec_()
self.assertTrue(my_obj.ok)
if __name__ == '__main__':
- QtCore.QCoreApplication()
+ QCoreApplication()
unittest.main()
diff --git a/sources/pyside6/tests/QtCore/snake_prop_feature_test.py b/sources/pyside6/tests/QtCore/snake_prop_feature_test.py
index ba58d52d1..01c8dd349 100644
--- a/sources/pyside6/tests/QtCore/snake_prop_feature_test.py
+++ b/sources/pyside6/tests/QtCore/snake_prop_feature_test.py
@@ -46,7 +46,7 @@ sys.path.append(os.fspath(Path(__file__).resolve().parents[1]))
from init_paths import init_test_paths
init_test_paths(False)
-from PySide6 import QtWidgets
+from PySide6.QtWidgets import QApplication, QWidget
from PySide6.support import __feature__
"""
@@ -58,14 +58,14 @@ Test the snake_case and true_property feature.
This works now, including class properties.
"""
-class Window(QtWidgets.QWidget):
+class Window(QWidget):
def __init__(self):
super(Window, self).__init__()
class FeatureTest(unittest.TestCase):
def setUp(self):
- qApp or QtWidgets.QApplication()
+ qApp or QApplication()
__feature__.set_selection(0)
def tearDown(self):
@@ -91,7 +91,7 @@ class FeatureTest(unittest.TestCase):
from __feature__ import snake_case, true_property
- self.assertTrue(isinstance(QtWidgets.QWidget.modal, property))
+ self.assertTrue(isinstance(QWidget.modal, property))
self.assertTrue(isinstance(window.modal, bool))
with self.assertRaises(AttributeError):
window.isModal
@@ -106,10 +106,10 @@ class FeatureTest(unittest.TestCase):
def testClassProperty(self):
from __feature__ import snake_case, true_property
# We check the class...
- self.assertEqual(type(QtWidgets.QApplication.quit_on_last_window_closed), bool)
- x = QtWidgets.QApplication.quit_on_last_window_closed
- QtWidgets.QApplication.quit_on_last_window_closed = not x
- self.assertEqual(QtWidgets.QApplication.quit_on_last_window_closed, not x)
+ self.assertEqual(type(QApplication.quit_on_last_window_closed), bool)
+ x = QApplication.quit_on_last_window_closed
+ QApplication.quit_on_last_window_closed = not x
+ self.assertEqual(QApplication.quit_on_last_window_closed, not x)
# ... and now the instance.
self.assertEqual(type(qApp.quit_on_last_window_closed), bool)
x = qApp.quit_on_last_window_closed
@@ -117,7 +117,7 @@ class FeatureTest(unittest.TestCase):
self.assertEqual(qApp.quit_on_last_window_closed, not x)
# make sure values are equal
self.assertEqual(qApp.quit_on_last_window_closed,
- QtWidgets.QApplication.quit_on_last_window_closed)
+ QApplication.quit_on_last_window_closed)
if __name__ == '__main__':
diff --git a/sources/pyside6/tests/QtGui/bug_1091.py b/sources/pyside6/tests/QtGui/bug_1091.py
index 22788fea0..1e5ae4ce6 100644
--- a/sources/pyside6/tests/QtGui/bug_1091.py
+++ b/sources/pyside6/tests/QtGui/bug_1091.py
@@ -37,12 +37,13 @@ sys.path.append(os.fspath(Path(__file__).resolve().parents[1]))
from init_paths import init_test_paths
init_test_paths(False)
-from PySide6 import QtGui
+from PySide6.QtGui import QPainter
+
class QPainterTestCase(unittest.TestCase):
def testIt(self):
- self.assertTrue("PixmapFragment" in dir(QtGui.QPainter))
- self.assertTrue("drawPixmapFragments" in dir(QtGui.QPainter))
+ self.assertTrue("PixmapFragment" in dir(QPainter))
+ self.assertTrue("drawPixmapFragments" in dir(QPainter))
if __name__ == "__main__":
unittest.main()
diff --git a/sources/pyside6/tests/QtGui/bug_367.py b/sources/pyside6/tests/QtGui/bug_367.py
index 0fd676d8b..2dfc140f4 100644
--- a/sources/pyside6/tests/QtGui/bug_367.py
+++ b/sources/pyside6/tests/QtGui/bug_367.py
@@ -38,14 +38,15 @@ from init_paths import init_test_paths
init_test_paths(False)
from helper.usesqapplication import UsesQApplication
-from PySide6 import QtCore,QtGui
+from PySide6.QtGui import QStandardItem, QStandardItemModel
+
class BugTest(UsesQApplication):
def testCase(self):
- model = QtGui.QStandardItemModel()
+ model = QStandardItemModel()
parentItem = model.invisibleRootItem()
for i in range(10):
- item = QtGui.QStandardItem()
+ item = QStandardItem()
rcount = sys.getrefcount(item)
parentItem.appendRow(item)
self.assertEqual(rcount+1, sys.getrefcount(item))
diff --git a/sources/pyside6/tests/QtGui/bug_480.py b/sources/pyside6/tests/QtGui/bug_480.py
index a7c863ba6..39707fb01 100644
--- a/sources/pyside6/tests/QtGui/bug_480.py
+++ b/sources/pyside6/tests/QtGui/bug_480.py
@@ -35,13 +35,15 @@ sys.path.append(os.fspath(Path(__file__).resolve().parents[1]))
from init_paths import init_test_paths
init_test_paths(False)
-from PySide6 import QtWidgets
+from PySide6.QtWidgets import (QApplication, QGridLayout, QLabel, QVBoxLayout,
+ QWidget)
-class BuggyWidget(QtWidgets.QWidget):
+
+class BuggyWidget(QWidget):
def setup(self):
- self.verticalLayout = QtWidgets.QVBoxLayout(self)
- self.gridLayout = QtWidgets.QGridLayout()
- self.lbl = QtWidgets.QLabel(self)
+ self.verticalLayout = QVBoxLayout(self)
+ self.gridLayout = QGridLayout()
+ self.lbl = QLabel(self)
self.gridLayout.addWidget(self.lbl, 0, 1, 1, 1)
# this cause a segfault during the ownership transfer
@@ -49,7 +51,7 @@ class BuggyWidget(QtWidgets.QWidget):
class LayoutTransferOwnerShip(unittest.TestCase):
def testBug(self):
- app = QtWidgets.QApplication([])
+ app = QApplication([])
w = BuggyWidget()
w.setup()
w.show()
diff --git a/sources/pyside6/tests/QtNetwork/bug_1084.py b/sources/pyside6/tests/QtNetwork/bug_1084.py
index a4bdbd9e2..4d794b8e7 100644
--- a/sources/pyside6/tests/QtNetwork/bug_1084.py
+++ b/sources/pyside6/tests/QtNetwork/bug_1084.py
@@ -37,12 +37,12 @@ sys.path.append(os.fspath(Path(__file__).resolve().parents[1]))
from init_paths import init_test_paths
init_test_paths(False)
-from PySide6 import QtNetwork
+from PySide6.QtNetwork import QTcpSocket
class QTcpSocketTestCase(unittest.TestCase):
def setUp(self):
- self.sock = QtNetwork.QTcpSocket()
+ self.sock = QTcpSocket()
self.sock.connectToHost('127.0.0.1', 25)
def testIt(self):
diff --git a/sources/pyside6/tests/QtQml/bug_451.py b/sources/pyside6/tests/QtQml/bug_451.py
index 7fd73ba90..d14f538a7 100644
--- a/sources/pyside6/tests/QtQml/bug_451.py
+++ b/sources/pyside6/tests/QtQml/bug_451.py
@@ -44,11 +44,14 @@ init_test_paths(False)
from helper.helper import quickview_errorstring
-from PySide6 import QtCore, QtGui, QtQuick
+from PySide6.QtCore import QObject, QUrl, Property
+from PySide6.QtGui import QGuiApplication
+from PySide6.QtQuick import QQuickView
-class PythonObject(QtCore.QObject):
+
+class PythonObject(QObject):
def __init__(self):
- QtCore.QObject.__init__(self, None)
+ super().__init__(None)
self._called = ""
self._arg1 = None
self._arg2 = None
@@ -71,21 +74,21 @@ class PythonObject(QtCore.QObject):
def getArg2(self):
return self._arg2
- called = QtCore.Property(str, getCalled, setCalled)
- arg1 = QtCore.Property(int, getArg1, setArg1)
- arg2 = QtCore.Property('QVariant', getArg2, setArg2)
+ called = Property(str, getCalled, setCalled)
+ arg1 = Property(int, getArg1, setArg1)
+ arg2 = Property('QVariant', getArg2, setArg2)
class TestBug(unittest.TestCase):
def testQMLFunctionCall(self):
- app = QtGui.QGuiApplication(sys.argv)
- view = QtQuick.QQuickView()
+ app = QGuiApplication(sys.argv)
+ view = QQuickView()
obj = PythonObject()
context = view.rootContext()
context.setContextProperty("python", obj)
file = Path(__file__).resolve().parent / 'bug_451.qml'
self.assertTrue(file.is_file())
- view.setSource(QtCore.QUrl.fromLocalFile(os.fspath(file)))
+ view.setSource(QUrl.fromLocalFile(os.fspath(file)))
root = view.rootObject()
self.assertTrue(root, quickview_errorstring(view))
root.simpleFunction()
diff --git a/sources/pyside6/tests/QtQml/bug_456.py b/sources/pyside6/tests/QtQml/bug_456.py
index 17028a902..ddb9819df 100644
--- a/sources/pyside6/tests/QtQml/bug_456.py
+++ b/sources/pyside6/tests/QtQml/bug_456.py
@@ -37,14 +37,15 @@ init_test_paths(False)
from helper.helper import quickview_errorstring
from helper.timedqapplication import TimedQApplication
+from PySide6.QtCore import QObject, QTimer, QUrl, Property, Slot
+from PySide6.QtQuick import QQuickView
-from PySide6 import QtCore, QtGui, QtQuick
-class RotateValue(QtCore.QObject):
+class RotateValue(QObject):
def __init__(self):
super(RotateValue,self).__init__()
- @QtCore.Slot(result=int)
+ @Slot(result=int)
def val(self):
return 100
@@ -54,25 +55,25 @@ class RotateValue(QtCore.QObject):
def getRotation(self):
return self._rotation
- rotation = QtCore.Property(int, getRotation, setRotation)
+ rotation = Property(int, getRotation, setRotation)
class TestConnectionWithInvalidSignature(TimedQApplication):
def testSlotRetur(self):
- view = QtQuick.QQuickView()
+ view = QQuickView()
rotatevalue = RotateValue()
- timer = QtCore.QTimer()
+ timer = QTimer()
timer.start(2000)
context = view.rootContext()
context.setContextProperty("rotatevalue", rotatevalue)
file = Path(__file__).resolve().parent / 'bug_456.qml'
self.assertTrue(file.is_file())
- view.setSource(QtCore.QUrl.fromLocalFile(os.fspath(file)))
+ view.setSource(QUrl.fromLocalFile(os.fspath(file)))
root = view.rootObject()
self.assertTrue(root, quickview_errorstring(view))
- button = root.findChild(QtCore.QObject, "buttonMouseArea")
+ button = root.findChild(QObject, "buttonMouseArea")
view.show()
button.entered.emit()
self.assertEqual(rotatevalue.rotation, 100)
diff --git a/sources/pyside6/tests/QtQml/bug_726.py b/sources/pyside6/tests/QtQml/bug_726.py
index aab597675..56712280c 100644
--- a/sources/pyside6/tests/QtQml/bug_726.py
+++ b/sources/pyside6/tests/QtQml/bug_726.py
@@ -37,25 +37,26 @@ init_test_paths(False)
from helper.helper import quickview_errorstring
from helper.timedqapplication import TimedQApplication
+from PySide6.QtCore import QObject, QUrl, Slot
+from PySide6.QtQuick import QQuickView
-from PySide6 import QtCore, QtGui, QtQuick
-class ProxyObject(QtCore.QObject):
+class ProxyObject(QObject):
def __init__(self):
super(ProxyObject,self).__init__()
self._o = None
self._receivedName = ""
- @QtCore.Slot(result='QObject*')
+ @Slot(result='QObject*')
def getObject(self):
if self._o:
return self._o
- self._o = QtCore.QObject()
+ self._o = QObject()
self._o.setObjectName("PySideObject")
return self._o
- @QtCore.Slot(str)
+ @Slot(str)
def receivedObject(self, name):
self._receivedName = name
@@ -63,17 +64,17 @@ class ProxyObject(QtCore.QObject):
class TestConnectionWithInvalidSignature(TimedQApplication):
def testSlotRetur(self):
- view = QtQuick.QQuickView()
+ view = QQuickView()
proxy = ProxyObject()
context = view.rootContext()
context.setContextProperty("proxy", proxy)
file = Path(__file__).resolve().parent / 'bug_726.qml'
self.assertTrue(file.is_file())
- view.setSource(QtCore.QUrl.fromLocalFile(os.fspath(file)))
+ view.setSource(QUrl.fromLocalFile(os.fspath(file)))
root = view.rootObject()
self.assertTrue(root, quickview_errorstring(view))
- button = root.findChild(QtCore.QObject, "buttonMouseArea")
+ button = root.findChild(QObject, "buttonMouseArea")
view.show()
button.entered.emit()
self.assertEqual(proxy._receivedName, "PySideObject")
diff --git a/sources/pyside6/tests/QtQml/bug_997.py b/sources/pyside6/tests/QtQml/bug_997.py
index 3d77e18e7..ce5ee14db 100644
--- a/sources/pyside6/tests/QtQml/bug_997.py
+++ b/sources/pyside6/tests/QtQml/bug_997.py
@@ -37,25 +37,27 @@ init_test_paths(False)
from helper.helper import quickview_errorstring
from helper.usesqapplication import UsesQApplication
+from PySide6.QtCore import QTimer, QUrl
+from PySide6.QtQml import QQmlPropertyMap
+from PySide6.QtQuick import QQuickView
-from PySide6 import QtCore, QtQml, QtQuick
class TestBug(UsesQApplication):
def testQMLFunctionCall(self):
- ownerData = QtQml.QQmlPropertyMap()
+ ownerData = QQmlPropertyMap()
ownerData.insert('name', 'John Smith')
ownerData.insert('phone', '555-5555')
ownerData.insert('newValue', '')
- view = QtQuick.QQuickView()
+ view = QQuickView()
ctxt = view.rootContext()
ctxt.setContextProperty('owner', ownerData)
file = Path(__file__).resolve().parent / 'bug_997.qml'
self.assertTrue(file.is_file())
- view.setSource(QtCore.QUrl.fromLocalFile(os.fspath(file)))
+ view.setSource(QUrl.fromLocalFile(os.fspath(file)))
self.assertTrue(view.rootObject(), quickview_errorstring(view))
view.show()
- QtCore.QTimer.singleShot(1000, self.app.quit)
+ QTimer.singleShot(1000, self.app.quit)
self.app.exec_()
self.assertEqual(ownerData.value('newName'), ownerData.value('name'))
diff --git a/sources/pyside6/tests/QtQml/connect_python_qml.py b/sources/pyside6/tests/QtQml/connect_python_qml.py
index 40b695b95..0b1e926cd 100644
--- a/sources/pyside6/tests/QtQml/connect_python_qml.py
+++ b/sources/pyside6/tests/QtQml/connect_python_qml.py
@@ -44,8 +44,10 @@ init_test_paths(False)
from helper.helper import quickview_errorstring
from helper.timedqapplication import TimedQApplication
+from PySide6.QtCore import QObject, QUrl, SIGNAL
+from PySide6.QtGui import QColor
+from PySide6.QtQuick import QQuickItem, QQuickView
-from PySide6 import QtCore, QtGui, QtQuick
class TestConnectionWithInvalidSignature(TimedQApplication):
def onButtonClicked(self):
@@ -58,14 +60,14 @@ class TestConnectionWithInvalidSignature(TimedQApplication):
def testFailConnection(self):
self.buttonClicked = False
self.buttonFailClicked = False
- view = QtQuick.QQuickView()
+ view = QQuickView()
file = Path(__file__).resolve().parent / 'connect_python_qml.qml'
self.assertTrue(file.is_file())
- view.setSource(QtCore.QUrl.fromLocalFile(os.fspath(file)))
+ view.setSource(QUrl.fromLocalFile(os.fspath(file)))
root = view.rootObject()
self.assertTrue(root, quickview_errorstring(view))
- button = root.findChild(QtCore.QObject, "buttonMouseArea")
- self.assertRaises(TypeError, QtCore.QObject.connect, [button,QtCore.SIGNAL('entered()'), self.onButtonFailClicked])
+ button = root.findChild(QObject, "buttonMouseArea")
+ self.assertRaises(TypeError, QObject.connect, [button,SIGNAL('entered()'), self.onButtonFailClicked])
button.entered.connect(self.onButtonClicked)
button.entered.emit()
view.show()
diff --git a/sources/pyside6/tests/QtQml/qquickitem_grabToImage.py b/sources/pyside6/tests/QtQml/qquickitem_grabToImage.py
index 36d6ac097..1b61ddbb0 100644
--- a/sources/pyside6/tests/QtQml/qquickitem_grabToImage.py
+++ b/sources/pyside6/tests/QtQml/qquickitem_grabToImage.py
@@ -37,25 +37,27 @@ init_test_paths(False)
from helper.helper import quickview_errorstring
from helper.timedqapplication import TimedQApplication
+from PySide6.QtCore import QTimer, QUrl
+from PySide6.QtGui import QColor
+from PySide6.QtQuick import QQuickItem, QQuickView
-from PySide6 import QtCore, QtGui, QtQuick
class TestGrabToSharedPointerImage(TimedQApplication):
def setUp(self):
TimedQApplication.setUp(self, 1000)
def testQQuickItemGrabToImageSharedPointer(self):
- view = QtQuick.QQuickView()
+ view = QQuickView()
file = Path(__file__).resolve().parent / 'qquickitem_grabToImage.qml'
self.assertTrue(file.is_file())
- view.setSource(QtCore.QUrl.fromLocalFile(os.fspath(file)))
+ view.setSource(QUrl.fromLocalFile(os.fspath(file)))
self.assertTrue(view.rootObject(), quickview_errorstring(view))
view.show()
# Get the QQuickItem objects for the blue Rectangle and the Image item.
root = view.rootObject()
- blueRectangle = root.findChild(QtQuick.QQuickItem, "blueRectangle")
- imageContainer = root.findChild(QtQuick.QQuickItem, "imageContainer")
+ blueRectangle = root.findChild(QQuickItem, "blueRectangle")
+ imageContainer = root.findChild(QQuickItem, "imageContainer")
# Start the image grabbing.
grabResultSharedPtr = blueRectangle.grabToImage()
@@ -67,7 +69,7 @@ class TestGrabToSharedPointerImage(TimedQApplication):
self.grabbedColor = None
def onGrabReady():
# Signal early exit.
- QtCore.QTimer.singleShot(0, self.app.quit)
+ QTimer.singleShot(0, self.app.quit)
# Show the grabbed image in the QML Image item.
imageContainer.setProperty("source", grabResultSharedPtr.url())
@@ -83,7 +85,7 @@ class TestGrabToSharedPointerImage(TimedQApplication):
self.assertTrue(self.grabbedColor.isValid())
# Compare the grabbed color with the one we set in the rectangle.
- blueColor = QtGui.QColor("blue")
+ blueColor = QColor("blue")
self.assertEqual(self.grabbedColor, blueColor)
diff --git a/sources/pyside6/tests/QtUiTools/bug_360.py b/sources/pyside6/tests/QtUiTools/bug_360.py
index 12327f813..e2edcea9f 100644
--- a/sources/pyside6/tests/QtUiTools/bug_360.py
+++ b/sources/pyside6/tests/QtUiTools/bug_360.py
@@ -36,10 +36,10 @@ from init_paths import init_test_paths
init_test_paths(False)
from helper.usesqapplication import UsesQApplication
-
-from PySide6 import QtCore, QtWidgets
+from PySide6.QtWidgets import QFrame, QWidget
from PySide6.QtUiTools import QUiLoader
+
class MyQUiLoader(QUiLoader):
def __init__(self, baseinstance):
QUiLoader.__init__(self)
@@ -57,14 +57,14 @@ class MyQUiLoader(QUiLoader):
class ButTest(UsesQApplication):
def testCase(self):
- w = QtWidgets.QWidget()
+ w = QWidget()
loader = MyQUiLoader(w)
filePath = os.path.join(os.path.dirname(__file__), 'minimal.ui')
ui = loader.load(filePath)
self.assertEqual(len(loader._widgets), 1)
- self.assertEqual(type(loader._widgets[0]), QtWidgets.QFrame)
+ self.assertEqual(type(loader._widgets[0]), QFrame)
if __name__ == '__main__':
unittest.main()
diff --git a/sources/pyside6/tests/QtUiTools/bug_376.py b/sources/pyside6/tests/QtUiTools/bug_376.py
index 05948118f..68138731c 100644
--- a/sources/pyside6/tests/QtUiTools/bug_376.py
+++ b/sources/pyside6/tests/QtUiTools/bug_376.py
@@ -37,17 +37,18 @@ init_test_paths(False)
from helper.usesqapplication import UsesQApplication
-from PySide6 import QtCore, QtWidgets
+from PySide6.QtWidgets import QFrame, QWidget
from PySide6.QtUiTools import QUiLoader
+
class BugTest(UsesQApplication):
def testCase(self):
- w = QtWidgets.QWidget()
+ w = QWidget()
loader = QUiLoader()
filePath = os.path.join(os.path.dirname(__file__), 'test.ui')
result = loader.load(filePath, w)
- self.assertTrue(isinstance(result.child_object, QtWidgets.QFrame))
+ self.assertTrue(isinstance(result.child_object, QFrame))
if __name__ == '__main__':
unittest.main()
diff --git a/sources/pyside6/tests/QtUiTools/bug_552.py b/sources/pyside6/tests/QtUiTools/bug_552.py
index a4c8ae630..345dfbac6 100644
--- a/sources/pyside6/tests/QtUiTools/bug_552.py
+++ b/sources/pyside6/tests/QtUiTools/bug_552.py
@@ -35,24 +35,26 @@ sys.path.append(os.fspath(Path(__file__).resolve().parents[1]))
from init_paths import init_test_paths
init_test_paths(False)
-from PySide6 import QtWidgets, QtCore
+from PySide6.QtCore import QObject
+from PySide6.QtWidgets import QApplication, QFrame, QWidget
from PySide6.QtUiTools import QUiLoader
-class View_1(QtWidgets.QWidget):
+
+class View_1(QWidget):
def __init__(self):
- QtWidgets.QWidget.__init__(self)
+ super().__init__()
loader = QUiLoader()
file = Path(__file__).resolve().parent / 'bug_552.ui'
assert(file.is_file())
widget = loader.load(os.fspath(file), self)
self.children = []
- for child in widget.findChildren(QtCore.QObject, None):
+ for child in widget.findChildren(QObject, None):
self.children.append(child)
self.t = widget.tabWidget
self.t.removeTab(0)
-app = QtWidgets.QApplication([])
+app = QApplication([])
window = View_1()
window.show()
diff --git a/sources/pyside6/tests/QtUiTools/bug_797.py b/sources/pyside6/tests/QtUiTools/bug_797.py
index 6bcb318da..ac9ec2dcc 100644
--- a/sources/pyside6/tests/QtUiTools/bug_797.py
+++ b/sources/pyside6/tests/QtUiTools/bug_797.py
@@ -35,16 +35,16 @@ sys.path.append(os.fspath(Path(__file__).resolve().parents[1]))
from init_paths import init_test_paths
init_test_paths(False)
-from PySide6 import QtUiTools
-from PySide6 import QtCore
-from PySide6 import QtWidgets
+from PySide6.QtUiTools import QUiLoader
+from PySide6.QtCore import QFile
+from PySide6.QtWidgets import QApplication, QWidget
-app = QtWidgets.QApplication([])
-loader = QtUiTools.QUiLoader()
+app = QApplication([])
+loader = QUiLoader()
file = Path(__file__).resolve().parent / 'bug_552.ui'
assert(file.is_file())
-file = QtCore.QFile(os.fspath(file))
-w = QtWidgets.QWidget()
+file = QFile(os.fspath(file))
+w = QWidget()
# An exception can't be thrown
mainWindow = loader.load(file, w)
diff --git a/sources/pyside6/tests/QtUiTools/bug_958.py b/sources/pyside6/tests/QtUiTools/bug_958.py
index f5cd57ba3..c2e072f64 100644
--- a/sources/pyside6/tests/QtUiTools/bug_958.py
+++ b/sources/pyside6/tests/QtUiTools/bug_958.py
@@ -35,14 +35,16 @@ sys.path.append(os.fspath(Path(__file__).resolve().parents[1]))
from init_paths import init_test_paths
init_test_paths(False)
-from PySide6 import QtWidgets, QtUiTools
+from PySide6.QtWidgets import QMainWindow
+from PySide6.QtUiTools import QUiLoader
from helper.timedqapplication import TimedQApplication
-class Gui_Qt(QtWidgets.QMainWindow):
+
+class Gui_Qt(QMainWindow):
def __init__(self, parent=None):
super(Gui_Qt, self).__init__(parent)
- lLoader = QtUiTools.QUiLoader()
+ lLoader = QUiLoader()
# this used to cause a segfault because the old inject code used to destroy the parent layout
file = Path(__file__).resolve().parent / 'bug_958.ui'
diff --git a/sources/pyside6/tests/QtWidgets/bug_1048.py b/sources/pyside6/tests/QtWidgets/bug_1048.py
index 18fc62782..0c5cdb0b5 100644
--- a/sources/pyside6/tests/QtWidgets/bug_1048.py
+++ b/sources/pyside6/tests/QtWidgets/bug_1048.py
@@ -35,11 +35,12 @@ sys.path.append(os.fspath(Path(__file__).resolve().parents[1] / "util"))
from init_paths import init_test_paths
init_test_paths()
-from PySide6 import QtWidgets
+from PySide6.QtWidgets import QApplication, QGridLayout, QWidget
-a = QtWidgets.QApplication([])
-w = QtWidgets.QWidget()
-l = QtWidgets.QGridLayout(w)
+a = QApplication([])
+
+w = QWidget()
+l = QGridLayout(w)
l.itemAtPosition(0, 0)
diff --git a/sources/pyside6/tests/QtWidgets/bug_1077.py b/sources/pyside6/tests/QtWidgets/bug_1077.py
index b736a558a..4c35e16bb 100644
--- a/sources/pyside6/tests/QtWidgets/bug_1077.py
+++ b/sources/pyside6/tests/QtWidgets/bug_1077.py
@@ -38,17 +38,18 @@ sys.path.append(os.fspath(Path(__file__).resolve().parents[1] / "util"))
from init_paths import init_test_paths
init_test_paths()
-from PySide6 import QtCore, QtGui, QtWidgets
+from PySide6.QtGui import QSyntaxHighlighter
+from PySide6.QtWidgets import QApplication, QTextEdit, QWidget
-class Highlighter(QtGui.QSyntaxHighlighter):
+class Highlighter(QSyntaxHighlighter):
def __init__(self, parent, mode):
- QtGui.QSyntaxHighlighter.__init__(self, parent)
+ super().__init__(parent)
self.tstamp = time.time()
if __name__ == "__main__":
- app = QtWidgets.QApplication([])
- python = QtWidgets.QTextEdit()
+ app = QApplication([])
+ python = QTextEdit()
python.setWindowTitle("python")
hl = Highlighter(python.document(), "python")
python.show()
diff --git a/sources/pyside6/tests/QtWidgets/bug_338.py b/sources/pyside6/tests/QtWidgets/bug_338.py
index cd3602b08..111417054 100644
--- a/sources/pyside6/tests/QtWidgets/bug_338.py
+++ b/sources/pyside6/tests/QtWidgets/bug_338.py
@@ -37,9 +37,10 @@ sys.path.append(os.fspath(Path(__file__).resolve().parents[1]))
from init_paths import init_test_paths
init_test_paths(False)
-from PySide6 import QtCore, QtWidgets
+from PySide6.QtWidgets import QApplication, QGraphicsPolygonItem, QGraphicsScene
-class DiagramItem(QtWidgets.QGraphicsPolygonItem):
+
+class DiagramItem(QGraphicsPolygonItem):
def __init__(self, parent=None, scene=None):
super(DiagramItem, self).__init__(parent, scene)
@@ -49,8 +50,8 @@ class DiagramItem(QtWidgets.QGraphicsPolygonItem):
class BugTest(unittest.TestCase):
def test(self):
- app = QtWidgets.QApplication(sys.argv)
- scene = QtWidgets.QGraphicsScene()
+ app = QApplication(sys.argv)
+ scene = QGraphicsScene()
item = DiagramItem()
item2 = DiagramItem()
#this cause segfault
diff --git a/sources/pyside6/tests/QtWidgets/bug_389.py b/sources/pyside6/tests/QtWidgets/bug_389.py
index fc8460a6b..3b0ca6a54 100644
--- a/sources/pyside6/tests/QtWidgets/bug_389.py
+++ b/sources/pyside6/tests/QtWidgets/bug_389.py
@@ -38,13 +38,15 @@ from init_paths import init_test_paths
init_test_paths(False)
from helper.usesqapplication import UsesQApplication
-from PySide6 import QtCore, QtGui, QtWidgets
+from PySide6.QtGui import QIcon
+from PySide6.QtWidgets import QStyle, QWidget
+
class BugTest(UsesQApplication):
def testCase(self):
- s = QtWidgets.QWidget().style()
- i = s.standardIcon(QtWidgets.QStyle.SP_TitleBarMinButton)
- self.assertEqual(type(i), QtGui.QIcon)
+ s = QWidget().style()
+ i = s.standardIcon(QStyle.SP_TitleBarMinButton)
+ self.assertEqual(type(i), QIcon)
if __name__ == '__main__':
unittest.main()
diff --git a/sources/pyside6/tests/QtWidgets/bug_433.py b/sources/pyside6/tests/QtWidgets/bug_433.py
index 1c8313d2a..a68a0615c 100644
--- a/sources/pyside6/tests/QtWidgets/bug_433.py
+++ b/sources/pyside6/tests/QtWidgets/bug_433.py
@@ -35,16 +35,18 @@ sys.path.append(os.fspath(Path(__file__).resolve().parents[1] / "util"))
from init_paths import init_test_paths
init_test_paths()
-from PySide6 import QtCore, QtWidgets
+from PySide6.QtCore import QTimer
+from PySide6.QtWidgets import QApplication, QGraphicsScene, QGraphicsView
-class Test(QtWidgets.QGraphicsView):
+
+class Test(QGraphicsView):
def __init__(self, parent=None):
super(Test, self).__init__(parent)
- self.s = QtWidgets.QGraphicsScene()
+ self.s = QGraphicsScene()
self.setScene(self.s)
-a = QtWidgets.QApplication(sys.argv)
+a = QApplication(sys.argv)
t = Test()
t.show()
-QtCore.QTimer.singleShot(0, t.close)
+QTimer.singleShot(0, t.close)
sys.exit(a.exec_())
diff --git a/sources/pyside6/tests/QtWidgets/bug_547.py b/sources/pyside6/tests/QtWidgets/bug_547.py
index a431f2dad..0753e932e 100644
--- a/sources/pyside6/tests/QtWidgets/bug_547.py
+++ b/sources/pyside6/tests/QtWidgets/bug_547.py
@@ -39,12 +39,13 @@ sys.path.append(os.fspath(Path(__file__).resolve().parents[1]))
from init_paths import init_test_paths
init_test_paths(False)
-from PySide6 import QtWidgets
+from PySide6.QtWidgets import QApplication, QTreeWidget, QTreeWidgetItem
+
class MyMainWindow(unittest.TestCase):
- app = QtWidgets.QApplication(sys.argv)
+ app = QApplication(sys.argv)
def testCase1(self):
- self._tree = QtWidgets.QTreeWidget()
+ self._tree = QTreeWidget()
self._tree.setColumnCount(2)
self._i1 = None
self._i11 = None
@@ -61,7 +62,7 @@ class MyMainWindow(unittest.TestCase):
self.assertEqual(sys.getrefcount(self._i11), 3)
def testCase2(self):
- self._tree = QtWidgets.QTreeWidget()
+ self._tree = QTreeWidget()
self._tree.setColumnCount(2)
self._i1 = None
self._i11 = None
@@ -82,9 +83,9 @@ class MyMainWindow(unittest.TestCase):
self.assertEqual(sys.getrefcount(self._i1), 2)
self.assertEqual(sys.getrefcount(self._i11), 2)
- self._i1 = QtWidgets.QTreeWidgetItem(self._tree, ['1', ])
+ self._i1 = QTreeWidgetItem(self._tree, ['1', ])
self.assertEqual(sys.getrefcount(self._i1), 3)
- self._i11 = QtWidgets.QTreeWidgetItem(self._i1, ['11', ])
+ self._i11 = QTreeWidgetItem(self._i1, ['11', ])
self.assertEqual(sys.getrefcount(self._i11), 3)
if __name__ == '__main__':
diff --git a/sources/pyside6/tests/QtWidgets/bug_576.py b/sources/pyside6/tests/QtWidgets/bug_576.py
index 784741b5e..b148f7c89 100644
--- a/sources/pyside6/tests/QtWidgets/bug_576.py
+++ b/sources/pyside6/tests/QtWidgets/bug_576.py
@@ -39,20 +39,22 @@ sys.path.append(os.fspath(Path(__file__).resolve().parents[1]))
from init_paths import init_test_paths
init_test_paths(False)
-from PySide6 import QtCore, QtWidgets
+from PySide6.QtCore import QObject
+from PySide6.QtWidgets import QApplication, QPushButton, QWidget
+
class Bug576(unittest.TestCase):
def onButtonDestroyed(self, button):
self._destroyed = True
- self.assertTrue(isinstance(button, QtWidgets.QPushButton))
+ self.assertTrue(isinstance(button, QPushButton))
def testWidgetParent(self):
self._destroyed = False
- app = QtWidgets.QApplication(sys.argv)
- w = QtWidgets.QWidget()
+ app = QApplication(sys.argv)
+ w = QWidget()
- b = QtWidgets.QPushButton("test")
- b.destroyed[QtCore.QObject].connect(self.onButtonDestroyed)
+ b = QPushButton("test")
+ b.destroyed[QObject].connect(self.onButtonDestroyed)
self.assertEqual(sys.getrefcount(b), 2)
b.setParent(w)
self.assertEqual(sys.getrefcount(b), 3)
diff --git a/sources/pyside6/tests/QtWidgets/bug_585.py b/sources/pyside6/tests/QtWidgets/bug_585.py
index 01e593349..eeb89c297 100644
--- a/sources/pyside6/tests/QtWidgets/bug_585.py
+++ b/sources/pyside6/tests/QtWidgets/bug_585.py
@@ -37,15 +37,16 @@ sys.path.append(os.fspath(Path(__file__).resolve().parents[1]))
from init_paths import init_test_paths
init_test_paths(False)
-from PySide6 import QtCore, QtWidgets
+from PySide6.QtWidgets import QApplication, QTreeWidget, QTreeWidgetItem
+
class Bug585(unittest.TestCase):
def testCase(self):
- app = QtWidgets.QApplication([])
- self._tree = QtWidgets.QTreeWidget()
+ app = QApplication([])
+ self._tree = QTreeWidget()
self._tree.setColumnCount(2)
- i1 = QtWidgets.QTreeWidgetItem(self._tree, ['1', ])
- i2 = QtWidgets.QTreeWidgetItem(self._tree, ['2', ])
+ i1 = QTreeWidgetItem(self._tree, ['1', ])
+ i2 = QTreeWidgetItem(self._tree, ['2', ])
refCount = sys.getrefcount(i1)
# this function return None
diff --git a/sources/pyside6/tests/QtWidgets/bug_589.py b/sources/pyside6/tests/QtWidgets/bug_589.py
index 249894c33..48faae17e 100644
--- a/sources/pyside6/tests/QtWidgets/bug_589.py
+++ b/sources/pyside6/tests/QtWidgets/bug_589.py
@@ -37,19 +37,19 @@ sys.path.append(os.fspath(Path(__file__).resolve().parents[1]))
from init_paths import init_test_paths
init_test_paths(False)
-from PySide6 import QtCore, QtWidgets
+from PySide6.QtWidgets import QApplication, QGraphicsProxyWidget
-class CustomWidget(QtWidgets.QGraphicsProxyWidget):
+class CustomWidget(QGraphicsProxyWidget):
def itemChange(self, eventType, value):
- QtWidgets.QGraphicsProxyWidget.itemChange(self, eventType, value)
+ QGraphicsProxyWidget.itemChange(self, eventType, value)
class Bug589(unittest.TestCase):
def testCase(self):
- widget = QtWidgets.QGraphicsProxyWidget()
+ widget = QGraphicsProxyWidget()
custom = CustomWidget()
custom.setParentItem(widget)
if __name__ == "__main__":
- app = QtWidgets.QApplication(sys.argv)
+ app = QApplication(sys.argv)
unittest.main()
diff --git a/sources/pyside6/tests/QtWidgets/bug_834.py b/sources/pyside6/tests/QtWidgets/bug_834.py
index 232d71c19..3a3926359 100644
--- a/sources/pyside6/tests/QtWidgets/bug_834.py
+++ b/sources/pyside6/tests/QtWidgets/bug_834.py
@@ -35,21 +35,23 @@ sys.path.append(os.fspath(Path(__file__).resolve().parents[1] / "util"))
from init_paths import init_test_paths
init_test_paths()
-from PySide6 import QtCore, QtWidgets
+from PySide6.QtCore import QTimer, Qt
+from PySide6.QtWidgets import QApplication, QDockWidget, QMainWindow
-class Window(QtWidgets.QMainWindow):
+
+class Window(QMainWindow):
def childEvent(self, event):
super(Window, self).childEvent(event)
-app = QtWidgets.QApplication([])
+app = QApplication([])
window = Window()
-dock1 = QtWidgets.QDockWidget()
-dock2 = QtWidgets.QDockWidget()
-window.addDockWidget(QtCore.Qt.LeftDockWidgetArea, dock1)
-window.addDockWidget(QtCore.Qt.LeftDockWidgetArea, dock2)
+dock1 = QDockWidget()
+dock2 = QDockWidget()
+window.addDockWidget(Qt.LeftDockWidgetArea, dock1)
+window.addDockWidget(Qt.LeftDockWidgetArea, dock2)
window.tabifyDockWidget(dock1, dock2)
window.show()
-QtCore.QTimer.singleShot(0, window.close)
+QTimer.singleShot(0, window.close)
app.exec_()
diff --git a/sources/pyside6/tests/QtWidgets/bug_921.py b/sources/pyside6/tests/QtWidgets/bug_921.py
index a7b0e99d4..9c7924efb 100644
--- a/sources/pyside6/tests/QtWidgets/bug_921.py
+++ b/sources/pyside6/tests/QtWidgets/bug_921.py
@@ -37,20 +37,21 @@ sys.path.append(os.fspath(Path(__file__).resolve().parents[1]))
from init_paths import init_test_paths
init_test_paths(False)
-from PySide6 import QtCore, QtWidgets
-
+from PySide6.QtCore import QObject, Signal, Qt
+from PySide6.QtWidgets import QMainWindow
from helper.timedqapplication import TimedQApplication
-class Signaller(QtCore.QObject):
- s1 = QtCore.Signal()
- s2 = QtCore.Signal()
- s3 = QtCore.Signal()
+
+class Signaller(QObject):
+ s1 = Signal()
+ s2 = Signal()
+ s3 = Signal()
class Window(object):
def __init__(self, s):
- self._window = QtWidgets.QMainWindow()
- self._window.setAttribute(QtCore.Qt.WA_DeleteOnClose, True)
+ self._window = QMainWindow()
+ self._window.setAttribute(Qt.WA_DeleteOnClose, True)
self._window.setWindowTitle("Demo!")
self._s = s
diff --git a/sources/pyside6/tests/QtWidgets/python_properties_test.py b/sources/pyside6/tests/QtWidgets/python_properties_test.py
index c12052315..4c90dce28 100644
--- a/sources/pyside6/tests/QtWidgets/python_properties_test.py
+++ b/sources/pyside6/tests/QtWidgets/python_properties_test.py
@@ -35,16 +35,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 QtCore, QtWidgets
+from PySide6.QtCore import QLocale
+from PySide6.QtWidgets import QGraphicsItem, QStyleOptionViewItem
+
class Properties(unittest.TestCase):
def testStaticProperty(self):
- self.assertEqual(QtWidgets.QGraphicsItem.UserType, 65536)
+ self.assertEqual(QGraphicsItem.UserType, 65536)
def testInstanceProperty(self):
- p = QtWidgets.QStyleOptionViewItem()
- self.assertTrue(isinstance(p.locale, QtCore.QLocale))
+ p = QStyleOptionViewItem()
+ self.assertTrue(isinstance(p.locale, QLocale))
# PSYIDE-304, can assign to a "const QWidget *" field
p.widget = None
diff --git a/sources/pyside6/tests/QtWidgets/qapp_issue_585.py b/sources/pyside6/tests/QtWidgets/qapp_issue_585.py
index 1b859db53..9e3674374 100644
--- a/sources/pyside6/tests/QtWidgets/qapp_issue_585.py
+++ b/sources/pyside6/tests/QtWidgets/qapp_issue_585.py
@@ -68,9 +68,10 @@ from init_paths import init_test_paths
init_test_paths()
from PySide6.QtCore import QTimer
-from PySide6 import QtWidgets
+from PySide6.QtWidgets import QApplication
-app_instance = QtWidgets.QApplication([])
+
+app_instance = QApplication([])
# If the following line is commented, application doesn't crash on exit anymore.
app_instance2 = app_instance
QTimer.singleShot(0, qApp.quit)
diff --git a/sources/pyside6/tests/QtWidgets/qfontdialog_test.py b/sources/pyside6/tests/QtWidgets/qfontdialog_test.py
index e0f834932..59c5dca3b 100644
--- a/sources/pyside6/tests/QtWidgets/qfontdialog_test.py
+++ b/sources/pyside6/tests/QtWidgets/qfontdialog_test.py
@@ -35,22 +35,21 @@ sys.path.append(os.fspath(Path(__file__).resolve().parents[1]))
from init_paths import init_test_paths
init_test_paths(False)
-from PySide6 import QtCore
-from PySide6 import QtGui
-from PySide6 import QtWidgets
-
+from PySide6.QtGui import QFont
+from PySide6.QtWidgets import QFontDialog
from helper.timedqapplication import TimedQApplication
+
class TestFontDialog(TimedQApplication):
def testGetFont(self):
- QtWidgets.QFontDialog.getFont()
+ QFontDialog.getFont()
def testGetFontQDialog(self):
- QtWidgets.QFontDialog.getFont(QtGui.QFont("FreeSans",10))
+ QFontDialog.getFont(QFont("FreeSans",10))
def testGetFontQDialogQString(self):
- QtWidgets.QFontDialog.getFont(QtGui.QFont("FreeSans",10), None, "Select font")
+ QFontDialog.getFont(QFont("FreeSans",10), None, "Select font")
if __name__ == '__main__':
unittest.main()
diff --git a/sources/pyside6/tests/QtWidgets/qgraphicsitem_isblocked_test.py b/sources/pyside6/tests/QtWidgets/qgraphicsitem_isblocked_test.py
index c03dde0c0..ed9485d0d 100644
--- a/sources/pyside6/tests/QtWidgets/qgraphicsitem_isblocked_test.py
+++ b/sources/pyside6/tests/QtWidgets/qgraphicsitem_isblocked_test.py
@@ -37,21 +37,22 @@ sys.path.append(os.fspath(Path(__file__).resolve().parents[1]))
from init_paths import init_test_paths
init_test_paths(False)
-from PySide6 import QtCore
-from PySide6 import QtGui
-from PySide6 import QtWidgets
+from PySide6.QtCore import QRectF
+from PySide6.QtWidgets import QGraphicsItem
+from PySide6.QtGui import QColor
from helper.usesqapplication import UsesQApplication
-class Item(QtWidgets.QGraphicsItem):
+
+class Item(QGraphicsItem):
def __init__(self):
- QtWidgets.QGraphicsItem.__init__(self)
+ super().__init__()
def boundingRect(self):
- return QtCore.QRectF(0, 0, 100, 100)
+ return QRectF(0, 0, 100, 100)
def paint(self, painter, option, widget):
- painter.setBrush(QtGui.QColor(255, 255, 255))
+ painter.setBrush(QColor(255, 255, 255))
painter.drawRect(0, 0, 100, 100)
diff --git a/sources/pyside6/tests/QtWidgets/qinputdialog_get_test.py b/sources/pyside6/tests/QtWidgets/qinputdialog_get_test.py
index f71434126..df3307d77 100644
--- a/sources/pyside6/tests/QtWidgets/qinputdialog_get_test.py
+++ b/sources/pyside6/tests/QtWidgets/qinputdialog_get_test.py
@@ -35,23 +35,24 @@ sys.path.append(os.fspath(Path(__file__).resolve().parents[1]))
from init_paths import init_test_paths
init_test_paths(False)
-from PySide6 import QtCore, QtWidgets
+from PySide6.QtWidgets import QInputDialog
from helper.timedqapplication import TimedQApplication
+
class TestInputDialog(TimedQApplication):
def testGetDouble(self):
- self.assertEqual(QtWidgets.QInputDialog.getDouble(None, "title", "label"), (0.0, False))
+ self.assertEqual(QInputDialog.getDouble(None, "title", "label"), (0.0, False))
def testGetInt(self):
- self.assertEqual(QtWidgets.QInputDialog.getInt(None, "title", "label"), (0, False))
+ self.assertEqual(QInputDialog.getInt(None, "title", "label"), (0, False))
def testGetItem(self):
- (item, bool) = QtWidgets.QInputDialog.getItem(None, "title", "label", ["1", "2", "3"])
+ (item, bool) = QInputDialog.getItem(None, "title", "label", ["1", "2", "3"])
self.assertEqual(str(item), "1")
def testGetText(self):
- (text, bool) = QtWidgets.QInputDialog.getText(None, "title", "label")
+ (text, bool) = QInputDialog.getText(None, "title", "label")
self.assertEqual(str(text),"")
if __name__ == '__main__':
diff --git a/sources/pyside6/tests/QtWidgets/qlistwidget_test.py b/sources/pyside6/tests/QtWidgets/qlistwidget_test.py
index f0f0790a3..5ca2507e9 100644
--- a/sources/pyside6/tests/QtWidgets/qlistwidget_test.py
+++ b/sources/pyside6/tests/QtWidgets/qlistwidget_test.py
@@ -35,17 +35,19 @@ sys.path.append(os.fspath(Path(__file__).resolve().parents[1]))
from init_paths import init_test_paths
init_test_paths(False)
-from PySide6 import QtWidgets, QtCore
+from PySide6.QtCore import QObject, QTimer, Qt
+from PySide6.QtWidgets import QListWidget, QListWidgetItem
from helper.usesqapplication import UsesQApplication
+
class QListWidgetTest(UsesQApplication):
def populateList(self, lst):
- o = QtCore.QObject()
+ o = QObject()
o.setObjectName("obj")
- item = QtWidgets.QListWidgetItem("item0")
- item.setData(QtCore.Qt.UserRole, o)
+ item = QListWidgetItem("item0")
+ item.setData(Qt.UserRole, o)
#item._data = o
self.assertTrue(sys.getrefcount(o), 3)
self.assertTrue(sys.getrefcount(item), 2)
@@ -58,13 +60,13 @@ class QListWidgetTest(UsesQApplication):
def checkItemData(self, lst):
item = lst.currentItem()
- o = item.data(QtCore.Qt.UserRole)
+ o = item.data(Qt.UserRole)
self.assertTrue(sys.getrefcount(o), 4)
self.assertEqual(o, item._data)
self.assertTrue(sys.getrefcount(o), 2)
def testConstructorWithParent(self):
- lst = QtWidgets.QListWidget()
+ lst = QListWidget()
self.populateList(lst)
self.checkCurrentItem(lst)
i = lst.item(0)
@@ -75,17 +77,17 @@ class QListWidgetTest(UsesQApplication):
del i
def testIt(self):
- lst = QtWidgets.QListWidget()
+ lst = QListWidget()
lst.show()
slot = lambda : lst.removeItemWidget(lst.currentItem())
- lst.addItem(QtWidgets.QListWidgetItem("foo"))
- QtCore.QTimer.singleShot(0, slot)
- QtCore.QTimer.singleShot(0, lst.close)
+ lst.addItem(QListWidgetItem("foo"))
+ QTimer.singleShot(0, slot)
+ QTimer.singleShot(0, lst.close)
self.app.exec_()
self.assertEqual(lst.count(), 1)
def testClear(self):
- lst = QtWidgets.QListWidget()
+ lst = QListWidget()
lst.addItem("foo")
item = lst.item(0)
self.assertIsNone(lst.clear())
diff --git a/sources/pyside6/tests/QtWidgets/qlistwidgetitem_test.py b/sources/pyside6/tests/QtWidgets/qlistwidgetitem_test.py
index 99744c8ea..7cfbfe3d1 100644
--- a/sources/pyside6/tests/QtWidgets/qlistwidgetitem_test.py
+++ b/sources/pyside6/tests/QtWidgets/qlistwidgetitem_test.py
@@ -35,15 +35,15 @@ sys.path.append(os.fspath(Path(__file__).resolve().parents[1]))
from init_paths import init_test_paths
init_test_paths(False)
-from PySide6 import QtWidgets
-
+from PySide6.QtWidgets import QListWidget, QListWidgetItem
from helper.usesqapplication import UsesQApplication
+
class QListWidgetItemConstructor(UsesQApplication):
def setUp(self):
super(QListWidgetItemConstructor, self).setUp()
- self.widgetList = QtWidgets.QListWidget()
+ self.widgetList = QListWidget()
def tearDown(self):
del self.widgetList
@@ -51,13 +51,13 @@ class QListWidgetItemConstructor(UsesQApplication):
def testConstructorWithParent(self):
# Bug 235 - QListWidgetItem constructor not saving ownership
- QtWidgets.QListWidgetItem(self.widgetList)
+ QListWidgetItem(self.widgetList)
item = self.widgetList.item(0)
self.assertEqual(item.listWidget(), self.widgetList)
def testConstructorWithNone(self):
# Bug 452 - QListWidgetItem() not casting NoneType to null correctly.
- item = QtWidgets.QListWidgetItem(None, 123)
+ item = QListWidgetItem(None, 123)
if __name__ == '__main__':
unittest.main()
diff --git a/sources/pyside6/tests/QtWidgets/qmainwindow_test.py b/sources/pyside6/tests/QtWidgets/qmainwindow_test.py
index fd60754fb..4ed726eb4 100644
--- a/sources/pyside6/tests/QtWidgets/qmainwindow_test.py
+++ b/sources/pyside6/tests/QtWidgets/qmainwindow_test.py
@@ -36,25 +36,25 @@ sys.path.append(os.fspath(Path(__file__).resolve().parents[1]))
from init_paths import init_test_paths
init_test_paths(False)
-from PySide6 import QtWidgets
-from PySide6 import QtCore
-
+from PySide6.QtCore import QTimer
+from PySide6.QtWidgets import QMainWindow, QPushButton, QToolButton, QWidget
from helper.usesqapplication import UsesQApplication
-class MainWindow(QtWidgets.QMainWindow):
+
+class MainWindow(QMainWindow):
def __init__(self):
- QtWidgets.QMainWindow.__init__(self)
+ super().__init__()
self.createToolbar()
def createToolbar(self):
- pointerButton = QtWidgets.QToolButton()
+ pointerButton = QToolButton()
pointerToolbar = self.addToolBar("Pointer type")
pointerToolbar.addWidget(pointerButton)
-class MyButton(QtWidgets.QPushButton):
+class MyButton(QPushButton):
def __init__(self, parent=None):
- QtWidgets.QPushButton.__init__(self)
+ super().__init__()
self._called = False
def myCallback(self):
@@ -66,15 +66,15 @@ class TestMainWindow(UsesQApplication):
def testCreateToolbar(self):
w = MainWindow()
w.show()
- QtCore.QTimer.singleShot(1000, self.app.quit)
+ QTimer.singleShot(1000, self.app.quit)
self.app.exec_()
def objDel(self, obj):
self.app.quit()
def testRefCountToNull(self):
- w = QtWidgets.QMainWindow()
- c = QtWidgets.QWidget()
+ w = QMainWindow()
+ c = QWidget()
self.assertEqual(sys.getrefcount(c), 2)
w.setCentralWidget(c)
self.assertEqual(sys.getrefcount(c), 3)
@@ -84,13 +84,13 @@ class TestMainWindow(UsesQApplication):
self.app.exec_()
def testRefCountToAnother(self):
- w = QtWidgets.QMainWindow()
- c = QtWidgets.QWidget()
+ w = QMainWindow()
+ c = QWidget()
self.assertEqual(sys.getrefcount(c), 2)
w.setCentralWidget(c)
self.assertEqual(sys.getrefcount(c), 3)
- c2 = QtWidgets.QWidget()
+ c2 = QWidget()
w.setCentralWidget(c2)
self.assertEqual(sys.getrefcount(c2), 3)
@@ -101,7 +101,7 @@ class TestMainWindow(UsesQApplication):
self.app.exec_()
def testSignalDisconect(self):
- w = QtWidgets.QMainWindow()
+ w = QMainWindow()
b = MyButton("button")
b.clicked.connect(b.myCallback)
w.setCentralWidget(b)
diff --git a/sources/pyside6/tests/QtWidgets/qmenuadd_test.py b/sources/pyside6/tests/QtWidgets/qmenuadd_test.py
index 6b9dad488..cbe738e53 100644
--- a/sources/pyside6/tests/QtWidgets/qmenuadd_test.py
+++ b/sources/pyside6/tests/QtWidgets/qmenuadd_test.py
@@ -39,17 +39,17 @@ sys.path.append(os.fspath(Path(__file__).resolve().parents[1]))
from init_paths import init_test_paths
init_test_paths(False)
-from PySide6 import QtWidgets
-
+from PySide6.QtWidgets import QMenu
from helper.usesqapplication import UsesQApplication
+
class QMenuAddAction(UsesQApplication):
def openFile(self, *args):
self.arg = args
def testQMenuAddAction(self):
- fileMenu = QtWidgets.QMenu("&File")
+ fileMenu = QMenu("&File")
addNewAction = fileMenu.addAction("&Open...", self.openFile)
addNewAction.trigger()
diff --git a/sources/pyside6/tests/QtWidgets/qtextedit_signal_test.py b/sources/pyside6/tests/QtWidgets/qtextedit_signal_test.py
index 9c7e51a40..4820d953b 100644
--- a/sources/pyside6/tests/QtWidgets/qtextedit_signal_test.py
+++ b/sources/pyside6/tests/QtWidgets/qtextedit_signal_test.py
@@ -35,22 +35,23 @@ sys.path.append(os.fspath(Path(__file__).resolve().parents[1]))
from init_paths import init_test_paths
init_test_paths(False)
-from PySide6 import QtCore, QtWidgets
+from PySide6.QtCore import Signal, Slot
+from PySide6.QtWidgets import QMainWindow, QPushButton, QTextEdit
from helper.usesqapplication import UsesQApplication
-class MyWindow(QtWidgets.QMainWindow):
- appendText = QtCore.Signal(str)
+class MyWindow(QMainWindow):
+ appendText = Signal(str)
- @QtCore.Slot()
+ @Slot()
def onButtonPressed(self):
self.appendText.emit("PySide")
def __init__(self, parent=None):
super(MyWindow, self).__init__(parent)
- self.textEdit = QtWidgets.QTextEdit()
- self.btn = QtWidgets.QPushButton("ClickMe")
+ self.textEdit = QTextEdit()
+ self.btn = QPushButton("ClickMe")
self.btn.clicked.connect(self.onButtonPressed)
self.appendText.connect(self.textEdit.append)
diff --git a/sources/pyside6/tests/QtWidgets/qtreewidgetitem_test.py b/sources/pyside6/tests/QtWidgets/qtreewidgetitem_test.py
index 28dfb07b5..ebd49012e 100644
--- a/sources/pyside6/tests/QtWidgets/qtreewidgetitem_test.py
+++ b/sources/pyside6/tests/QtWidgets/qtreewidgetitem_test.py
@@ -49,15 +49,16 @@ sys.path.append(os.fspath(Path(__file__).resolve().parents[1]))
from init_paths import init_test_paths
init_test_paths(False)
-from PySide6 import QtCore, QtWidgets
+from PySide6.QtCore import QTimer
+from PySide6.QtWidgets import QApplication, QTreeWidget, QTreeWidgetItem
class QTreeWidgetItemTest(unittest.TestCase):
def testClass(self):
- app = QtWidgets.QApplication([])
- treewidget = QtWidgets.QTreeWidget()
- item = QtWidgets.QTreeWidgetItem(["Words and stuff"])
- item2 = QtWidgets.QTreeWidgetItem(["More words!"])
+ app = QApplication([])
+ treewidget = QTreeWidget()
+ item = QTreeWidgetItem(["Words and stuff"])
+ item2 = QTreeWidgetItem(["More words!"])
treewidget.insertTopLevelItem(0, item)
dummy_list = ["Numbers", "Symbols", "Spam"]
@@ -66,7 +67,7 @@ class QTreeWidgetItemTest(unittest.TestCase):
self.assertFalse(item == item2)
self.assertTrue(item != item2)
treewidget.show()
- QtCore.QTimer.singleShot(500, app.quit)
+ QTimer.singleShot(500, app.quit)
app.exec_()
diff --git a/sources/pyside6/tests/QtWidgets/wrong_return_test.py b/sources/pyside6/tests/QtWidgets/wrong_return_test.py
index df0368599..019010f50 100644
--- a/sources/pyside6/tests/QtWidgets/wrong_return_test.py
+++ b/sources/pyside6/tests/QtWidgets/wrong_return_test.py
@@ -38,14 +38,14 @@ sys.path.append(os.fspath(Path(__file__).resolve().parents[1]))
from init_paths import init_test_paths
init_test_paths(False)
-from PySide6 import QtWidgets
+from PySide6.QtWidgets import QWidget
from helper.usesqapplication import UsesQApplication
warnings.simplefilter('error')
-class MyWidget(QtWidgets.QWidget):
+class MyWidget(QWidget):
def __init__(self, parent=None):
super(MyWidget, self).__init__(parent)
diff --git a/sources/pyside6/tests/pysidetest/mixin_signal_slots_test.py b/sources/pyside6/tests/pysidetest/mixin_signal_slots_test.py
index b192a5180..45a3a608a 100644
--- a/sources/pyside6/tests/pysidetest/mixin_signal_slots_test.py
+++ b/sources/pyside6/tests/pysidetest/mixin_signal_slots_test.py
@@ -42,57 +42,58 @@ sys.path.append(os.fspath(Path(__file__).resolve().parents[1]))
from init_paths import init_test_paths
init_test_paths(False)
-from PySide6 import QtCore
+from PySide6.QtCore import QObject, Signal, Slot
+
class Mixin(object):
- mixinSignal = QtCore.Signal()
+ mixinSignal = Signal()
def __init__(self, *args, **kwargs):
super(Mixin,self).__init__(*args, **kwargs)
class MixinTwo(Mixin):
- mixinTwoSignal = QtCore.Signal()
+ mixinTwoSignal = Signal()
def __init__(self, *args, **kwargs):
super(MixinTwo,self).__init__(*args, **kwargs)
self.mixinTwoSlotCalled = False
- @QtCore.Slot()
+ @Slot()
def mixinTwoSlot(self):
self.mixinTwoSlotCalled = True
class MixinThree(object):
- mixinThreeSignal = QtCore.Signal()
+ mixinThreeSignal = Signal()
def __init__(self, *args, **kwargs):
super(MixinThree,self).__init__(*args, **kwargs)
self.mixinThreeSlotCalled = False
- @QtCore.Slot()
+ @Slot()
def mixinThreeSlot(self):
self.mixinThreeSlotCalled = True
-class Derived(Mixin, QtCore.QObject):
- derivedSignal = QtCore.Signal(str)
+class Derived(Mixin, QObject):
+ derivedSignal = Signal(str)
def __init__(self):
super(Derived,self).__init__()
self.derivedSlotCalled = False
self.derivedSlotString = ''
- @QtCore.Slot(str)
+ @Slot(str)
def derivedSlot(self, theString):
self.derivedSlotCalled = True
self.derivedSlotString = theString
-class MultipleDerived(MixinTwo, MixinThree, Mixin, QtCore.QObject):
- derivedSignal = QtCore.Signal(str)
+class MultipleDerived(MixinTwo, MixinThree, Mixin, QObject):
+ derivedSignal = Signal(str)
def __init__(self):
super(MultipleDerived,self).__init__()
self.derivedSlotCalled = False
self.derivedSlotString = ''
- @QtCore.Slot(str)
+ @Slot(str)
def derivedSlot(self, theString):
self.derivedSlotCalled = True
self.derivedSlotString = theString
@@ -120,7 +121,7 @@ class MixinTest(unittest.TestCase):
# Check derivedSignal emission after mixingSignal connection
self.outsideSlotCalled = False
- @QtCore.Slot()
+ @Slot()
def outsideSlot():
self.outsideSlotCalled = True
@@ -169,7 +170,7 @@ class MixinTest(unittest.TestCase):
# Check derivedSignal emission after mixinThreeSignal connection
self.outsideSlotCalled = False
- @QtCore.Slot()
+ @Slot()
def outsideSlot():
self.outsideSlotCalled = True
diff --git a/sources/pyside6/tests/pysidetest/signal_tp_descr_get_test.py b/sources/pyside6/tests/pysidetest/signal_tp_descr_get_test.py
index 037862fb6..4e7bc1c3f 100644
--- a/sources/pyside6/tests/pysidetest/signal_tp_descr_get_test.py
+++ b/sources/pyside6/tests/pysidetest/signal_tp_descr_get_test.py
@@ -52,7 +52,7 @@ sys.path.append(os.fspath(Path(__file__).resolve().parents[1]))
from init_paths import init_test_paths
init_test_paths(False)
-from PySide6 import QtCore
+from PySide6.QtCore import QObject, Signal
def emit_upon_success(signal):
@@ -66,8 +66,8 @@ def emit_upon_success(signal):
return f_
-class Foo(QtCore.QObject):
- SIG = QtCore.Signal()
+class Foo(QObject):
+ SIG = Signal()
@emit_upon_success(SIG)
def do_something(self):
diff --git a/sources/pyside6/tests/pysidetest/version_test.py b/sources/pyside6/tests/pysidetest/version_test.py
index 15e126c1d..aba4da9c0 100644
--- a/sources/pyside6/tests/pysidetest/version_test.py
+++ b/sources/pyside6/tests/pysidetest/version_test.py
@@ -37,7 +37,8 @@ sys.path.append(os.fspath(Path(__file__).resolve().parents[1]))
from init_paths import init_test_paths
init_test_paths(False)
-from PySide6 import __version_info__, __version__, QtCore
+from PySide6 import __version_info__, __version__
+
class CheckForVariablesTest(unittest.TestCase):
def testVesions(self):
@@ -47,8 +48,8 @@ class CheckForVariablesTest(unittest.TestCase):
self.assertTrue(version_tuple < (99, 99, 99))
self.assertTrue(__version__)
- self.assertTrue(QtCore.__version_info__ >= (4, 5, 0))
- self.assertTrue(QtCore.__version__)
+ self.assertTrue(__version_info__ >= (4, 5, 0))
+ self.assertTrue(__version__)
if __name__ == '__main__':
unittest.main()
diff --git a/sources/pyside6/tests/signals/bug_189.py b/sources/pyside6/tests/signals/bug_189.py
index f13a9c2cc..ef3c0483b 100644
--- a/sources/pyside6/tests/signals/bug_189.py
+++ b/sources/pyside6/tests/signals/bug_189.py
@@ -35,9 +35,11 @@ sys.path.append(os.fspath(Path(__file__).resolve().parents[1]))
from init_paths import init_test_paths
init_test_paths(False)
-from PySide6 import QtCore, QtWidgets
+from PySide6.QtCore import QTimer
+from PySide6.QtWidgets import QSlider
from helper.usesqapplication import UsesQApplication
+
class TestBugPYSIDE189(UsesQApplication):
def testDisconnect(self):
@@ -46,12 +48,12 @@ class TestBugPYSIDE189(UsesQApplication):
def onValueChanged(self, value):
pass
- sld = QtWidgets.QSlider()
+ sld = QSlider()
sld.valueChanged.connect(onValueChanged)
sld.deleteLater()
- QtCore.QTimer.singleShot(0, self.app.quit)
+ QTimer.singleShot(0, self.app.quit)
self.app.exec_()
self.assertRaises(RuntimeError, sld.valueChanged.disconnect, onValueChanged)
diff --git a/sources/pyside6/tests/signals/bug_311.py b/sources/pyside6/tests/signals/bug_311.py
index 6772f89b7..449734c33 100644
--- a/sources/pyside6/tests/signals/bug_311.py
+++ b/sources/pyside6/tests/signals/bug_311.py
@@ -38,17 +38,17 @@ sys.path.append(os.fspath(Path(__file__).resolve().parents[1]))
from init_paths import init_test_paths
init_test_paths(False)
-from PySide6 import QtCore
+from PySide6.QtCore import QDate, QObject, Signal
from helper.usesqcoreapplication import UsesQCoreApplication
-class DerivedDate(QtCore.QDate):
+class DerivedDate(QDate):
def __init__(self,y,m,d):
super(DerivedDate,self).__init__(y,m,d)
-class Emitter(QtCore.QObject):
- dateSignal1 = QtCore.Signal(QtCore.QDate)
- dateSignal2 = QtCore.Signal(DerivedDate)
- tupleSignal = QtCore.Signal(tuple)
+class Emitter(QObject):
+ dateSignal1 = Signal(QDate)
+ dateSignal2 = Signal(DerivedDate)
+ tupleSignal = Signal(tuple)
class SignaltoSignalTest(UsesQCoreApplication):
def myCb(self, dt):
diff --git a/sources/pyside6/tests/signals/bug_319.py b/sources/pyside6/tests/signals/bug_319.py
index 563447cfe..87dc9c053 100644
--- a/sources/pyside6/tests/signals/bug_319.py
+++ b/sources/pyside6/tests/signals/bug_319.py
@@ -38,22 +38,23 @@ sys.path.append(os.fspath(Path(__file__).resolve().parents[1]))
from init_paths import init_test_paths
init_test_paths(False)
-from PySide6 import QtCore
+from PySide6.QtCore import QObject, Signal, Slot
from helper.usesqcoreapplication import UsesQCoreApplication
-class Listener(QtCore.QObject):
+
+class Listener(QObject):
def __init__(self):
- QtCore.QObject.__init__(self, None)
+ super().__init__(None)
self._phrase = []
- @QtCore.Slot(tuple)
+ @Slot(tuple)
def listen(self, words):
for w in words:
self._phrase.append(w)
-class Communicate(QtCore.QObject):
+class Communicate(QObject):
# create a new signal on the fly and name it 'speak'
- speak = QtCore.Signal(tuple)
+ speak = Signal(tuple)
class SignaltoSignalTest(UsesQCoreApplication):
def testBug(self):
diff --git a/sources/pyside6/tests/signals/bug_79.py b/sources/pyside6/tests/signals/bug_79.py
index 3b97e036c..9b91a8825 100644
--- a/sources/pyside6/tests/signals/bug_79.py
+++ b/sources/pyside6/tests/signals/bug_79.py
@@ -36,7 +36,9 @@ sys.path.append(os.fspath(Path(__file__).resolve().parents[1]))
from init_paths import init_test_paths
init_test_paths(False)
-from PySide6 import QtGui, QtWidgets
+from PySide6.QtGui import QStandardItemModel
+from PySide6.QtWidgets import QApplication, QTreeView
+
try:
from sys import gettotalrefcount
@@ -52,9 +54,9 @@ class ConnectTest(unittest.TestCase):
def testNoLeaks_ConnectAndDisconnect(self):
self._called = None
- app = QtWidgets.QApplication([])
- o = QtWidgets.QTreeView()
- o.setModel(QtGui.QStandardItemModel())
+ app = QApplication([])
+ o = QTreeView()
+ o.setModel(QStandardItemModel())
o.selectionModel().destroyed.connect(self.callback)
o.selectionModel().destroyed.disconnect(self.callback)
gc.collect()
diff --git a/sources/pyside6/tests/signals/leaking_signal_test.py b/sources/pyside6/tests/signals/leaking_signal_test.py
index 170637d93..35662b36a 100644
--- a/sources/pyside6/tests/signals/leaking_signal_test.py
+++ b/sources/pyside6/tests/signals/leaking_signal_test.py
@@ -36,15 +36,15 @@ sys.path.append(os.fspath(Path(__file__).resolve().parents[1]))
from init_paths import init_test_paths
init_test_paths(False)
-from PySide6 import QtCore
+from PySide6.QtCore import QObject, Signal
class LeakingSignal(unittest.TestCase):
def testLeakingSignal(self):
# Was segfaulting when the signal was garbage collected.
- class Emitter(QtCore.QObject):
- my_signal = QtCore.Signal(object)
+ class Emitter(QObject):
+ my_signal = Signal(object)
emitter = Emitter()
diff --git a/sources/pyside6/tests/signals/signal_number_limit_test.py b/sources/pyside6/tests/signals/signal_number_limit_test.py
index edf3ec077..6f54b73de 100644
--- a/sources/pyside6/tests/signals/signal_number_limit_test.py
+++ b/sources/pyside6/tests/signals/signal_number_limit_test.py
@@ -38,23 +38,24 @@ sys.path.append(os.fspath(Path(__file__).resolve().parents[1]))
from init_paths import init_test_paths
init_test_paths(False)
-from PySide6 import QtCore
+from PySide6.QtCore import QObject, Signal
-class Emitter(QtCore.QObject):
- s1 = QtCore.Signal()
- s2 = QtCore.Signal()
- s3 = QtCore.Signal()
- s4 = QtCore.Signal()
- s5 = QtCore.Signal()
- s6 = QtCore.Signal()
- s7 = QtCore.Signal()
- s8 = QtCore.Signal()
- s9 = QtCore.Signal()
- s10 = QtCore.Signal()
- s11 = QtCore.Signal()
- s12 = QtCore.Signal()
- s13 = QtCore.Signal()
- s14 = QtCore.Signal()
+
+class Emitter(QObject):
+ s1 = Signal()
+ s2 = Signal()
+ s3 = Signal()
+ s4 = Signal()
+ s5 = Signal()
+ s6 = Signal()
+ s7 = Signal()
+ s8 = Signal()
+ s9 = Signal()
+ s10 = Signal()
+ s11 = Signal()
+ s12 = Signal()
+ s13 = Signal()
+ s14 = Signal()
class SignalNumberLimitTest(unittest.TestCase):
def myCb(self):