aboutsummaryrefslogtreecommitdiffstats
path: root/sources
diff options
context:
space:
mode:
authorFriedemann Kleint <[email protected]>2024-12-19 08:35:05 +0100
committerFriedemann Kleint <[email protected]>2024-12-20 13:16:11 +0100
commitfcfb6d1c5b983753dd3e65a592a11c17f32bd0ff (patch)
treec313983f4dbd92861cba94bde13f6b756bbe7cc9 /sources
parenta88b7fc378bfa2481e581adc9de981dbd263ddc4 (diff)
PySide6/Tests: Use fully qualified enumerations
As a drive-by fix flake errors. Pick-to: 6.8 Task-number: PYSIDE-1735 Change-Id: I9829b011fee78fc8edd1aefdd3066ae89e63644b Reviewed-by: Shyamnath Premnadh <[email protected]>
Diffstat (limited to 'sources')
-rw-r--r--sources/pyside6/tests/QtCore/blocking_signals_test.py4
-rw-r--r--sources/pyside6/tests/QtCore/bug_1063.py2
-rw-r--r--sources/pyside6/tests/QtCore/bug_1069.py2
-rw-r--r--sources/pyside6/tests/QtCore/bug_408.py2
-rw-r--r--sources/pyside6/tests/QtCore/bug_462.py4
-rw-r--r--sources/pyside6/tests/QtCore/bug_826.py4
-rw-r--r--sources/pyside6/tests/QtCore/bug_829.py10
-rw-r--r--sources/pyside6/tests/QtCore/bug_938.py2
-rw-r--r--sources/pyside6/tests/QtCore/bug_994.py2
-rw-r--r--sources/pyside6/tests/QtCore/bug_PYSIDE-164.py2
-rw-r--r--sources/pyside6/tests/QtCore/deepcopy_test.py2
-rw-r--r--sources/pyside6/tests/QtCore/qabstractitemmodel_test.py4
-rw-r--r--sources/pyside6/tests/QtCore/qbytearray_test.py2
-rw-r--r--sources/pyside6/tests/QtCore/qcollator_test.py16
-rw-r--r--sources/pyside6/tests/QtCore/qdatastream_test.py22
-rw-r--r--sources/pyside6/tests/QtCore/qenum_test.py14
-rw-r--r--sources/pyside6/tests/QtCore/qevent_test.py12
-rw-r--r--sources/pyside6/tests/QtCore/qfile_test.py6
-rw-r--r--sources/pyside6/tests/QtCore/qflags_test.py58
-rw-r--r--sources/pyside6/tests/QtCore/qlinef_test.py2
-rw-r--r--sources/pyside6/tests/QtCore/qlocale_test.py14
-rw-r--r--sources/pyside6/tests/QtCore/qmessageauthenticationcode_test.py3
-rw-r--r--sources/pyside6/tests/QtCore/qmetaobject_test.py2
-rw-r--r--sources/pyside6/tests/QtCore/qobject_parent_test.py8
-rw-r--r--sources/pyside6/tests/QtCore/qobject_test.py4
-rw-r--r--sources/pyside6/tests/QtCore/qprocess_test.py2
-rw-r--r--sources/pyside6/tests/QtCore/qresource_test.py4
-rw-r--r--sources/pyside6/tests/QtCore/qsettings_test.py6
-rw-r--r--sources/pyside6/tests/QtCore/qsocketnotifier_test.py4
-rw-r--r--sources/pyside6/tests/QtCore/qsysinfo_test.py8
-rw-r--r--sources/pyside6/tests/QtCore/qtextstream_test.py7
-rw-r--r--sources/pyside6/tests/QtCore/qtimezone_test.py3
-rw-r--r--sources/pyside6/tests/QtCore/repr_test.py2
-rw-r--r--sources/pyside6/tests/QtCore/signal_sender.py2
-rw-r--r--sources/pyside6/tests/QtGui/bug_493.py8
-rw-r--r--sources/pyside6/tests/QtGui/bug_617.py2
-rw-r--r--sources/pyside6/tests/QtGui/bug_740.py5
-rw-r--r--sources/pyside6/tests/QtGui/event_filter_test.py2
-rw-r--r--sources/pyside6/tests/QtGui/float_to_int_implicit_conversion_test.py2
-rw-r--r--sources/pyside6/tests/QtGui/qbrush_test.py4
-rw-r--r--sources/pyside6/tests/QtGui/qcolor_test.py2
-rw-r--r--sources/pyside6/tests/QtGui/qdatastream_gui_operators_test.py8
-rw-r--r--sources/pyside6/tests/QtGui/qfontmetrics_test.py86
-rw-r--r--sources/pyside6/tests/QtGui/qimage_test.py6
-rw-r--r--sources/pyside6/tests/QtGui/qimage_win_test.py4
-rw-r--r--sources/pyside6/tests/QtGui/qkeysequence_test.py11
-rw-r--r--sources/pyside6/tests/QtGui/qpainter_test.py12
-rw-r--r--sources/pyside6/tests/QtGui/qpdfwriter_test.py4
-rw-r--r--sources/pyside6/tests/QtGui/qpen_test.py10
-rw-r--r--sources/pyside6/tests/QtGui/qpixelformat_test.py11
-rw-r--r--sources/pyside6/tests/QtGui/qpixmap_test.py7
-rw-r--r--sources/pyside6/tests/QtGui/qrasterwindow_test.py10
-rw-r--r--sources/pyside6/tests/QtGui/qshortcut_test.py4
-rw-r--r--sources/pyside6/tests/QtGui/qtextdocument_functions.py6
-rw-r--r--sources/pyside6/tests/QtGui/qtextdocumentwriter_test.py2
-rw-r--r--sources/pyside6/tests/QtGui/qtextline_test.py2
-rw-r--r--sources/pyside6/tests/QtNetwork/bug_446.py3
-rw-r--r--sources/pyside6/tests/QtNetwork/dnslookup_test.py4
-rw-r--r--sources/pyside6/tests/QtNetwork/qhostinfo_test.py2
-rw-r--r--sources/pyside6/tests/QtNetwork/qpassworddigestor_test.py2
-rw-r--r--sources/pyside6/tests/QtNetwork/udpsocket_test.py4
-rw-r--r--sources/pyside6/tests/QtOpenGL/qopenglbuffer_test.py12
-rw-r--r--sources/pyside6/tests/QtOpenGL/qopenglwindow_test.py6
-rw-r--r--sources/pyside6/tests/QtQml/bug_814.py4
-rw-r--r--sources/pyside6/tests/QtQml/bug_825.py2
-rw-r--r--sources/pyside6/tests/QtQml/bug_825_old.py2
-rw-r--r--sources/pyside6/tests/QtQml/bug_847.py4
-rw-r--r--sources/pyside6/tests/QtQml/qqmlincubator_incubateWhile.py16
-rw-r--r--sources/pyside6/tests/QtQml/qqmlnetwork_test.py2
-rw-r--r--sources/pyside6/tests/QtQml/qquickview_test.py4
-rw-r--r--sources/pyside6/tests/QtQml/registertype.py2
-rw-r--r--sources/pyside6/tests/QtQml/registeruncreatabletype.py2
-rw-r--r--sources/pyside6/tests/QtSerialPort/serial.py26
-rw-r--r--sources/pyside6/tests/QtSvg/qsvgrenderer_test.py2
-rw-r--r--sources/pyside6/tests/QtSvgWidgets/qsvgwidget_test.py2
-rw-r--r--sources/pyside6/tests/QtTest/click_test.py4
-rw-r--r--sources/pyside6/tests/QtTest/eventfilter_test.py8
-rw-r--r--sources/pyside6/tests/QtTest/qvalidator_test.py14
-rw-r--r--sources/pyside6/tests/QtWebEngineCore/web_engine_custom_scheme.py15
-rw-r--r--sources/pyside6/tests/QtWidgets/add_action_test.py8
-rw-r--r--sources/pyside6/tests/QtWidgets/api2_test.py4
-rw-r--r--sources/pyside6/tests/QtWidgets/bug_1006.py4
-rw-r--r--sources/pyside6/tests/QtWidgets/bug_389.py2
-rw-r--r--sources/pyside6/tests/QtWidgets/bug_688.py4
-rw-r--r--sources/pyside6/tests/QtWidgets/bug_736.py6
-rw-r--r--sources/pyside6/tests/QtWidgets/bug_879.py3
-rw-r--r--sources/pyside6/tests/QtWidgets/bug_919.py2
-rw-r--r--sources/pyside6/tests/QtWidgets/bug_921.py2
-rw-r--r--sources/pyside6/tests/QtWidgets/bug_941.py7
-rw-r--r--sources/pyside6/tests/QtWidgets/bug_964.py5
-rw-r--r--sources/pyside6/tests/QtWidgets/bug_972.py13
-rw-r--r--sources/pyside6/tests/QtWidgets/customproxywidget_test.py9
-rw-r--r--sources/pyside6/tests/QtWidgets/qaccessible_test.py6
-rw-r--r--sources/pyside6/tests/QtWidgets/qdynamic_signal.py10
-rw-r--r--sources/pyside6/tests/QtWidgets/qformlayout_test.py6
-rw-r--r--sources/pyside6/tests/QtWidgets/qgraphicsproxywidget_test.py9
-rw-r--r--sources/pyside6/tests/QtWidgets/qlayout_test.py20
-rw-r--r--sources/pyside6/tests/QtWidgets/qlistwidget_test.py4
-rw-r--r--sources/pyside6/tests/QtWidgets/qobject_mi_test.py4
-rw-r--r--sources/pyside6/tests/QtWidgets/qpushbutton_test.py2
-rw-r--r--sources/pyside6/tests/QtWidgets/qtreeview_test.py2
-rw-r--r--sources/pyside6/tests/QtWidgets/qvariant_test.py4
-rw-r--r--sources/pyside6/tests/QtWidgets/standardpixmap_test.py2
-rw-r--r--sources/pyside6/tests/pysidetest/constructor_properties_test.py38
-rw-r--r--sources/pyside6/tests/pysidetest/delegatecreateseditor_test.py6
-rw-r--r--sources/pyside6/tests/pysidetest/enum_test.py12
-rw-r--r--sources/pyside6/tests/pysidetest/new_inherited_functions_test.py19
-rw-r--r--sources/pyside6/tests/pysidetest/qvariant_test.py13
-rw-r--r--sources/pyside6/tests/signals/pysignal_test.py4
-rw-r--r--sources/pyside6/tests/signals/signal_connectiontype_support_test.py2
-rw-r--r--sources/pyside6/tests/signals/signal_emission_test.py16
-rw-r--r--sources/pyside6/tests/signals/signal_newenum_test.py2
-rw-r--r--sources/pyside6/tests/signals/signal_object_test.py2
113 files changed, 440 insertions, 403 deletions
diff --git a/sources/pyside6/tests/QtCore/blocking_signals_test.py b/sources/pyside6/tests/QtCore/blocking_signals_test.py
index 48d8ab7b9..0f8425095 100644
--- a/sources/pyside6/tests/QtCore/blocking_signals_test.py
+++ b/sources/pyside6/tests/QtCore/blocking_signals_test.py
@@ -139,14 +139,14 @@ class TestQFileSignalBlocking(unittest.TestCase):
self.qfile.aboutToClose.connect(self.callback)
- self.assertTrue(self.qfile.open(QFile.ReadOnly))
+ self.assertTrue(self.qfile.open(QFile.OpenModeFlag.ReadOnly))
self.qfile.close()
self.assertTrue(self.called)
self.called = False
self.qfile.blockSignals(True)
- self.assertTrue(self.qfile.open(QFile.ReadOnly))
+ self.assertTrue(self.qfile.open(QFile.OpenModeFlag.ReadOnly))
self.qfile.close()
self.assertTrue(not self.called)
diff --git a/sources/pyside6/tests/QtCore/bug_1063.py b/sources/pyside6/tests/QtCore/bug_1063.py
index fec6836a1..fb8627e23 100644
--- a/sources/pyside6/tests/QtCore/bug_1063.py
+++ b/sources/pyside6/tests/QtCore/bug_1063.py
@@ -22,7 +22,7 @@ class QTextStreamTestCase(unittest.TestCase):
self.temp_file = tempfile.NamedTemporaryFile(delete=False)
self.temp_file.close()
self.f = QFile(self.temp_file.name)
- self.f.open(QIODevice.WriteOnly)
+ self.f.open(QIODevice.OpenModeFlag.WriteOnly)
self.strings = ('foo', 'bar')
self.stream = QTextStream(self.f)
diff --git a/sources/pyside6/tests/QtCore/bug_1069.py b/sources/pyside6/tests/QtCore/bug_1069.py
index 746897a80..85766225d 100644
--- a/sources/pyside6/tests/QtCore/bug_1069.py
+++ b/sources/pyside6/tests/QtCore/bug_1069.py
@@ -19,7 +19,7 @@ from PySide6.QtCore import QByteArray, QDataStream, QIODevice
class QDataStreamOpOverloadTestCase(unittest.TestCase):
def setUp(self):
self.ba = QByteArray()
- self.stream = QDataStream(self.ba, QIODevice.WriteOnly)
+ self.stream = QDataStream(self.ba, QIODevice.OpenModeFlag.WriteOnly)
def testIt(self):
self.stream << "hello"
diff --git a/sources/pyside6/tests/QtCore/bug_408.py b/sources/pyside6/tests/QtCore/bug_408.py
index e8bc45636..2fb886e57 100644
--- a/sources/pyside6/tests/QtCore/bug_408.py
+++ b/sources/pyside6/tests/QtCore/bug_408.py
@@ -31,7 +31,7 @@ class QIODeviceTest(unittest.TestCase):
def testIt(self):
device = MyDevice("hello world\nhello again")
- device.open(QIODevice.ReadOnly)
+ device.open(QIODevice.OpenModeFlag.ReadOnly)
s = QTextStream(device)
self.assertEqual(s.readLine(), "hello world")
diff --git a/sources/pyside6/tests/QtCore/bug_462.py b/sources/pyside6/tests/QtCore/bug_462.py
index 830a4c148..c10eb5593 100644
--- a/sources/pyside6/tests/QtCore/bug_462.py
+++ b/sources/pyside6/tests/QtCore/bug_462.py
@@ -16,8 +16,8 @@ from PySide6.QtCore import QObject, QCoreApplication, QEvent, QThread
class MyEvent(QEvent):
def __init__(self, i):
- print("TYPE:", type(QEvent.User))
- super().__init__(QEvent.Type(QEvent.User))
+ print("TYPE:", type(QEvent.Type.User))
+ super().__init__(QEvent.Type(QEvent.Type.User))
self.i = i
diff --git a/sources/pyside6/tests/QtCore/bug_826.py b/sources/pyside6/tests/QtCore/bug_826.py
index c30df13fa..7ac0fd895 100644
--- a/sources/pyside6/tests/QtCore/bug_826.py
+++ b/sources/pyside6/tests/QtCore/bug_826.py
@@ -30,8 +30,8 @@ class TestEvent(QEvent):
class TestEnums(unittest.TestCase):
def testUserTypesValues(self):
- self.assertTrue(QEvent.User <= TestEvent.TestEventType <= QEvent.MaxUser)
- self.assertTrue(QEvent.User <= TEST_EVENT_TYPE <= QEvent.MaxUser)
+ self.assertTrue(QEvent.Type.User <= TestEvent.TestEventType <= QEvent.Type.MaxUser)
+ self.assertTrue(QEvent.Type.User <= TEST_EVENT_TYPE <= QEvent.Type.MaxUser)
if __name__ == '__main__':
diff --git a/sources/pyside6/tests/QtCore/bug_829.py b/sources/pyside6/tests/QtCore/bug_829.py
index 89790c001..9158ab35b 100644
--- a/sources/pyside6/tests/QtCore/bug_829.py
+++ b/sources/pyside6/tests/QtCore/bug_829.py
@@ -31,19 +31,19 @@ class QVariantConversions(unittest.TestCase):
del confFile
# PYSIDE-535: Need to collect garbage in PyPy to trigger deletion
gc.collect()
- s = QSettings(self._confFileName, QSettings.IniFormat)
- self.assertEqual(s.status(), QSettings.NoError)
+ s = QSettings(self._confFileName, QSettings.Format.IniFormat)
+ self.assertEqual(s.status(), QSettings.Status.NoError)
# Save value
s.setValue('x', {1: 'a'})
s.sync()
- self.assertEqual(s.status(), QSettings.NoError)
+ self.assertEqual(s.status(), QSettings.Status.NoError)
del s
# PYSIDE-535: Need to collect garbage in PyPy to trigger deletion
gc.collect()
# Restore value
- s = QSettings(self._confFileName, QSettings.IniFormat)
- self.assertEqual(s.status(), QSettings.NoError)
+ s = QSettings(self._confFileName, QSettings.Format.IniFormat)
+ self.assertEqual(s.status(), QSettings.Status.NoError)
self.assertEqual(s.value('x'), {1: 'a'})
def __del__(self):
diff --git a/sources/pyside6/tests/QtCore/bug_938.py b/sources/pyside6/tests/QtCore/bug_938.py
index 63607cd40..90df0cf53 100644
--- a/sources/pyside6/tests/QtCore/bug_938.py
+++ b/sources/pyside6/tests/QtCore/bug_938.py
@@ -18,7 +18,7 @@ class TestBug938 (unittest.TestCase):
def testIt(self):
b = QBuffer()
- b.open(QBuffer.WriteOnly)
+ b.open(QBuffer.OpenModeFlag.WriteOnly)
b.write(bytes("\x0023\x005", "UTF-8"))
b.close()
self.assertEqual(b.buffer().size(), 5)
diff --git a/sources/pyside6/tests/QtCore/bug_994.py b/sources/pyside6/tests/QtCore/bug_994.py
index 258d40dd8..5f76e5620 100644
--- a/sources/pyside6/tests/QtCore/bug_994.py
+++ b/sources/pyside6/tests/QtCore/bug_994.py
@@ -29,7 +29,7 @@ class TestBug944 (unittest.TestCase):
def testIt(self):
device = MyIODevice()
- device.open(QIODevice.ReadOnly)
+ device.open(QIODevice.OpenModeFlag.ReadOnly)
s = QTextStream(device)
self.assertEqual(s.read(4), "\0a\0a")
self.assertEqual(device.readLine(), "\0b\0b\0b\0b")
diff --git a/sources/pyside6/tests/QtCore/bug_PYSIDE-164.py b/sources/pyside6/tests/QtCore/bug_PYSIDE-164.py
index 2a082eeb6..fed0f9fdf 100644
--- a/sources/pyside6/tests/QtCore/bug_PYSIDE-164.py
+++ b/sources/pyside6/tests/QtCore/bug_PYSIDE-164.py
@@ -44,7 +44,7 @@ class TestBugPYSIDE164(unittest.TestCase):
eventloop = QEventLoop()
emitter = Emitter()
receiver = Receiver(eventloop)
- emitter.signal.connect(receiver.receive, Qt.BlockingQueuedConnection)
+ emitter.signal.connect(receiver.receive, Qt.ConnectionType.BlockingQueuedConnection)
emitter.start()
retval = eventloop.exec()
emitter.wait(2000)
diff --git a/sources/pyside6/tests/QtCore/deepcopy_test.py b/sources/pyside6/tests/QtCore/deepcopy_test.py
index c41f7bbb0..8b211a979 100644
--- a/sources/pyside6/tests/QtCore/deepcopy_test.py
+++ b/sources/pyside6/tests/QtCore/deepcopy_test.py
@@ -45,7 +45,7 @@ class QTimeDeepCopy(DeepCopyHelper, unittest.TestCase):
class QDateTimeDeepCopy(DeepCopyHelper, unittest.TestCase):
def setUp(self):
- self.original = QDateTime(2010, 5, 18, 10, 24, 45, 223, Qt.LocalTime)
+ self.original = QDateTime(2010, 5, 18, 10, 24, 45, 223, Qt.TimeSpec.LocalTime)
class QSizeDeepCopy(DeepCopyHelper, unittest.TestCase):
diff --git a/sources/pyside6/tests/QtCore/qabstractitemmodel_test.py b/sources/pyside6/tests/QtCore/qabstractitemmodel_test.py
index f1b0f8b0b..ef729650c 100644
--- a/sources/pyside6/tests/QtCore/qabstractitemmodel_test.py
+++ b/sources/pyside6/tests/QtCore/qabstractitemmodel_test.py
@@ -50,11 +50,11 @@ class TestQModelIndexInternalPointer(unittest.TestCase):
def testQIdentityProxyModel(self):
sourceModel = QStringListModel(['item1', 'item2'])
sourceIndex = sourceModel.index(0, 0)
- sourceData = str(sourceModel.data(sourceIndex, Qt.DisplayRole))
+ sourceData = str(sourceModel.data(sourceIndex, Qt.ItemDataRole.DisplayRole))
proxyModel = QIdentityProxyModel()
proxyModel.setSourceModel(sourceModel)
proxyIndex = proxyModel.mapFromSource(sourceIndex)
- proxyData = str(proxyModel.data(proxyIndex, Qt.DisplayRole))
+ proxyData = str(proxyModel.data(proxyIndex, Qt.ItemDataRole.DisplayRole))
self.assertEqual(sourceData, proxyData)
def testMultiDataModel(self):
diff --git a/sources/pyside6/tests/QtCore/qbytearray_test.py b/sources/pyside6/tests/QtCore/qbytearray_test.py
index 6f130ad6e..cb0fbbb68 100644
--- a/sources/pyside6/tests/QtCore/qbytearray_test.py
+++ b/sources/pyside6/tests/QtCore/qbytearray_test.py
@@ -108,7 +108,7 @@ class QByteArrayOnQDataStream(unittest.TestCase):
'''
def testIt(self):
a = QByteArray()
- b = QDataStream(a, QIODevice.WriteOnly)
+ b = QDataStream(a, QIODevice.OpenModeFlag.WriteOnly)
b.writeUInt16(5000)
# The __repr__ not suppose to crash anymore
self.assertNotEqual(repr(b), None)
diff --git a/sources/pyside6/tests/QtCore/qcollator_test.py b/sources/pyside6/tests/QtCore/qcollator_test.py
index d189280d7..ba43c904d 100644
--- a/sources/pyside6/tests/QtCore/qcollator_test.py
+++ b/sources/pyside6/tests/QtCore/qcollator_test.py
@@ -20,23 +20,23 @@ from PySide6.QtCore import QCollator, QLocale, Qt
class QCollatorTest(unittest.TestCase):
def testState(self):
c = QCollator()
- c.setCaseSensitivity(Qt.CaseInsensitive)
- c.setLocale(QLocale.German)
+ c.setCaseSensitivity(Qt.CaseSensitivity.CaseInsensitive)
+ c.setLocale(QLocale.Language.German)
print("compare a and b:", c.compare("a", "b"))
- self.assertEqual(c.caseSensitivity(), Qt.CaseInsensitive)
- self.assertEqual(c.locale(), QLocale(QLocale.German))
+ self.assertEqual(c.caseSensitivity(), Qt.CaseSensitivity.CaseInsensitive)
+ self.assertEqual(c.locale(), QLocale(QLocale.Language.German))
- c.setLocale(QLocale.French)
+ c.setLocale(QLocale.Language.French)
c.setNumericMode(True)
c.setIgnorePunctuation(True)
- c.setLocale(QLocale.NorwegianBokmal)
+ c.setLocale(QLocale.Language.NorwegianBokmal)
- self.assertEqual(c.caseSensitivity(), Qt.CaseInsensitive)
+ self.assertEqual(c.caseSensitivity(), Qt.CaseSensitivity.CaseInsensitive)
self.assertEqual(c.numericMode(), True)
self.assertEqual(c.ignorePunctuation(), True)
- self.assertEqual(c.locale(), QLocale(QLocale.NorwegianBokmal))
+ self.assertEqual(c.locale(), QLocale(QLocale.Language.NorwegianBokmal))
if __name__ == '__main__':
diff --git a/sources/pyside6/tests/QtCore/qdatastream_test.py b/sources/pyside6/tests/QtCore/qdatastream_test.py
index 5850974a1..564a5d059 100644
--- a/sources/pyside6/tests/QtCore/qdatastream_test.py
+++ b/sources/pyside6/tests/QtCore/qdatastream_test.py
@@ -28,7 +28,7 @@ def create_bitarray(string):
def serialize_bitarray(bit_array):
buffer = QByteArray()
- stream = QDataStream(buffer, QIODevice.WriteOnly)
+ stream = QDataStream(buffer, QIODevice.OpenModeFlag.WriteOnly)
stream << bit_array
return buffer
@@ -38,8 +38,8 @@ class QDataStreamWrite(unittest.TestCase):
def setUp(self):
self.ba = QByteArray()
- self.read = QDataStream(self.ba, QIODevice.ReadOnly)
- self.write = QDataStream(self.ba, QIODevice.WriteOnly)
+ self.read = QDataStream(self.ba, QIODevice.OpenModeFlag.ReadOnly)
+ self.write = QDataStream(self.ba, QIODevice.OpenModeFlag.WriteOnly)
def testWriteUInt8(self):
'''QDataStream.writeUInt8 (accepting str of size 1)'''
@@ -93,8 +93,8 @@ class QDataStreamShift(unittest.TestCase):
def setUp(self):
self.ba = QByteArray()
- self.stream = QDataStream(self.ba, QIODevice.WriteOnly)
- self.read_stream = QDataStream(self.ba, QIODevice.ReadOnly)
+ self.stream = QDataStream(self.ba, QIODevice.OpenModeFlag.WriteOnly)
+ self.read_stream = QDataStream(self.ba, QIODevice.OpenModeFlag.ReadOnly)
def testQCharValid(self):
'''QDataStream <<>> QChar - valid'''
@@ -256,7 +256,7 @@ class QDataStreamShiftBitArray(unittest.TestCase):
'''Check the >> operator for the given data set'''
for data, expectedStatus, expectedString in data_set:
- stream = QDataStream(data, QIODevice.ReadOnly)
+ stream = QDataStream(data, QIODevice.OpenModeFlag.ReadOnly)
string = QBitArray()
stream >> string
@@ -274,14 +274,14 @@ class QDataStreamShiftBitArray(unittest.TestCase):
data = []
for expected in test_set:
- data.append((serialize_bitarray(expected), QDataStream.Ok, expected))
+ data.append((serialize_bitarray(expected), QDataStream.Status.Ok, expected))
self._check_bitarray(data)
def testPastEnd(self):
'''QDataStream >> QBitArray reading past the end of the data'''
serialized = serialize_bitarray(create_bitarray('1001110'))
serialized.resize(serialized.size() - 2)
- self._check_bitarray([(serialized, QDataStream.ReadPastEnd, QBitArray())])
+ self._check_bitarray([(serialized, QDataStream.Status.ReadPastEnd, QBitArray())])
class QDataStreamBuffer(unittest.TestCase):
@@ -290,7 +290,7 @@ class QDataStreamBuffer(unittest.TestCase):
self.assertEqual(data.readRawData(4), None)
ba = QByteArray()
- data = QDataStream(ba, QIODevice.WriteOnly)
+ data = QDataStream(ba, QIODevice.OpenModeFlag.WriteOnly)
data.writeRawData('AB\x00C')
self.assertEqual(ba.data(), bytes('AB\x00C', "UTF-8"))
@@ -301,7 +301,7 @@ class QDataStreamBuffer(unittest.TestCase):
test_data = b'AB\0'
data = QDataStream()
ba = QByteArray()
- data = QDataStream(ba, QIODevice.WriteOnly)
+ data = QDataStream(ba, QIODevice.OpenModeFlag.WriteOnly)
data.writeRawData(test_data)
self.assertEqual(ba.data(), test_data)
data = QDataStream(ba)
@@ -312,7 +312,7 @@ class QDataStreamBuffer(unittest.TestCase):
self.assertEqual(dataOne.readBytes(4), None)
ba = QByteArray()
- data = QDataStream(ba, QIODevice.WriteOnly)
+ data = QDataStream(ba, QIODevice.OpenModeFlag.WriteOnly)
# writeBytes() writes a quint32 containing the length of the data,
# followed by the data.
data.writeBytes(bytes('AB\x00C', 'UTF-8'))
diff --git a/sources/pyside6/tests/QtCore/qenum_test.py b/sources/pyside6/tests/QtCore/qenum_test.py
index c3122276f..58115295f 100644
--- a/sources/pyside6/tests/QtCore/qenum_test.py
+++ b/sources/pyside6/tests/QtCore/qenum_test.py
@@ -50,22 +50,22 @@ class TestEnum(unittest.TestCase):
class TestQFlags(unittest.TestCase):
def testToItn(self):
- om = QIODevice.NotOpen
+ om = QIODevice.OpenModeFlag.NotOpen
omcmp = om.value
- self.assertEqual(om, QIODevice.NotOpen)
+ self.assertEqual(om, QIODevice.OpenModeFlag.NotOpen)
self.assertTrue(omcmp == 0)
- self.assertTrue(omcmp != QIODevice.ReadOnly)
+ self.assertTrue(omcmp != QIODevice.OpenModeFlag.ReadOnly)
self.assertTrue(omcmp != 1)
def testToIntInFunction(self):
- om = QIODevice.WriteOnly
+ om = QIODevice.OpenModeFlag.WriteOnly
self.assertEqual(int(om.value), 2)
def testNonExtensibleEnums(self):
try:
- om = QIODevice.OpenMode(QIODevice.WriteOnly) # noqa: F841
+ om = QIODevice.OpenMode(QIODevice.OpenModeFlag.WriteOnly) # noqa: F841
self.assertFail()
except: # noqa: E722
pass
@@ -76,8 +76,8 @@ class TestEnumPickling(unittest.TestCase):
def testPickleEnum(self):
# Pickling of enums with different depth works.
- ret = pickle.loads(pickle.dumps(QIODevice.Append))
- self.assertEqual(ret, QIODevice.Append)
+ ret = pickle.loads(pickle.dumps(QIODevice.OpenModeFlag.Append))
+ self.assertEqual(ret, QIODevice.OpenModeFlag.Append)
ret = pickle.loads(pickle.dumps(Qt.Key.Key_Asterisk))
self.assertEqual(ret, Qt.Key.Key_Asterisk)
diff --git a/sources/pyside6/tests/QtCore/qevent_test.py b/sources/pyside6/tests/QtCore/qevent_test.py
index d2ab7d1eb..5527e4c6b 100644
--- a/sources/pyside6/tests/QtCore/qevent_test.py
+++ b/sources/pyside6/tests/QtCore/qevent_test.py
@@ -23,14 +23,14 @@ class QEventTypeFlag(unittest.TestCase):
def testFlagAccess(self):
# QEvent.Type flags usage
- event = QEvent(QEvent.Timer)
- self.assertEqual(event.type(), QEvent.Timer)
+ event = QEvent(QEvent.Type.Timer)
+ self.assertEqual(event.type(), QEvent.Type.Timer)
- event = QEvent(QEvent.Close)
- self.assertEqual(event.type(), QEvent.Close)
+ event = QEvent(QEvent.Type.Close)
+ self.assertEqual(event.type(), QEvent.Type.Close)
- event = QEvent(QEvent.IconTextChange)
- self.assertEqual(event.type(), QEvent.IconTextChange)
+ event = QEvent(QEvent.Type.IconTextChange)
+ self.assertEqual(event.type(), QEvent.Type.IconTextChange)
if __name__ == '__main__':
diff --git a/sources/pyside6/tests/QtCore/qfile_test.py b/sources/pyside6/tests/QtCore/qfile_test.py
index 4535159de..ffac43975 100644
--- a/sources/pyside6/tests/QtCore/qfile_test.py
+++ b/sources/pyside6/tests/QtCore/qfile_test.py
@@ -31,7 +31,7 @@ class GetCharTest(unittest.TestCase):
def testBasic(self):
'''QFile.getChar'''
obj = QFile(self.filename)
- obj.open(QIODevice.ReadOnly)
+ obj.open(QIODevice.OpenModeFlag.ReadOnly)
try:
self.assertEqual(obj.getChar(), (True, 'a'))
self.assertFalse(obj.getChar()[0])
@@ -40,7 +40,7 @@ class GetCharTest(unittest.TestCase):
def testBug721(self):
obj = QFile(self.filename)
- obj.open(QIODevice.ReadOnly)
+ obj.open(QIODevice.OpenModeFlag.ReadOnly)
try:
memory = obj.map(0, 1)
self.assertEqual(len(memory), 1)
@@ -56,7 +56,7 @@ class GetCharTest(unittest.TestCase):
dir = QTemporaryDir(QDir.tempPath() + "/XXXXXX.dir")
self.assertTrue(dir.isValid())
saveFile = QSaveFile(dir.path() + "/test.dat")
- self.assertTrue(saveFile.open(QIODevice.WriteOnly))
+ self.assertTrue(saveFile.open(QIODevice.OpenModeFlag.WriteOnly))
saveFile.write(bytes("Test", "UTF-8"))
self.assertTrue(saveFile.commit())
self.assertTrue(os.path.exists(QDir.toNativeSeparators(saveFile.fileName())))
diff --git a/sources/pyside6/tests/QtCore/qflags_test.py b/sources/pyside6/tests/QtCore/qflags_test.py
index 5fc83ff58..f5722fd0d 100644
--- a/sources/pyside6/tests/QtCore/qflags_test.py
+++ b/sources/pyside6/tests/QtCore/qflags_test.py
@@ -27,12 +27,16 @@ class QFlagTest(unittest.TestCase):
f.close()
f = QFile(fileName)
- self.assertEqual(f.open(QIODevice.Truncate | QIODevice.Text | QIODevice.ReadWrite), True)
+ of = (QIODevice.OpenModeFlag.Truncate | QIODevice.OpenModeFlag.Text
+ | QIODevice.OpenModeFlag.ReadWrite)
+ self.assertEqual(f.open(of), True)
om = f.openMode()
- self.assertEqual(om & QIODevice.Truncate, QIODevice.Truncate)
- self.assertEqual(om & QIODevice.Text, QIODevice.Text)
- self.assertEqual(om & QIODevice.ReadWrite, QIODevice.ReadWrite)
- self.assertTrue(om == QIODevice.Truncate | QIODevice.Text | QIODevice.ReadWrite)
+ self.assertEqual(om & QIODevice.OpenModeFlag.Truncate, QIODevice.OpenModeFlag.Truncate)
+ self.assertEqual(om & QIODevice.OpenModeFlag.Text, QIODevice.OpenModeFlag.Text)
+ self.assertEqual(om & QIODevice.OpenModeFlag.ReadWrite, QIODevice.OpenModeFlag.ReadWrite)
+ expected = (QIODevice.OpenModeFlag.Truncate | QIODevice.OpenModeFlag.Text
+ | QIODevice.OpenModeFlag.ReadWrite)
+ self.assertTrue(om == expected)
f.close()
@@ -41,53 +45,57 @@ class QFlagOperatorTest(unittest.TestCase):
def testInvert(self):
'''QFlags ~ (invert) operator'''
- self.assertEqual(type(~QIODevice.ReadOnly), QIODevice.OpenMode)
+ self.assertEqual(type(~QIODevice.OpenModeFlag.ReadOnly), QIODevice.OpenMode)
def testOr(self):
'''QFlags | (or) operator'''
- self.assertEqual(type(QIODevice.ReadOnly | QIODevice.WriteOnly), QIODevice.OpenMode)
+ self.assertEqual(type(QIODevice.OpenModeFlag.ReadOnly | QIODevice.OpenModeFlag.WriteOnly),
+ QIODevice.OpenMode)
def testAnd(self):
'''QFlags & (and) operator'''
- self.assertEqual(type(QIODevice.ReadOnly & QIODevice.WriteOnly), QIODevice.OpenMode)
+ self.assertEqual(type(QIODevice.OpenModeFlag.ReadOnly & QIODevice.OpenModeFlag.WriteOnly),
+ QIODevice.OpenMode)
def testIOr(self):
'''QFlags |= (ior) operator'''
flag = Qt.WindowFlags()
- self.assertTrue(Qt.Widget == 0)
- self.assertFalse(flag & Qt.Widget)
- result = flag & Qt.Widget
+ self.assertTrue(Qt.WindowType.Widget == 0)
+ self.assertFalse(flag & Qt.WindowType.Widget)
+ result = flag & Qt.WindowType.Widget
self.assertTrue(result == 0)
- flag |= Qt.WindowMinimizeButtonHint
- self.assertTrue(flag & Qt.WindowMinimizeButtonHint)
+ flag |= Qt.WindowType.WindowMinimizeButtonHint
+ self.assertTrue(flag & Qt.WindowType.WindowMinimizeButtonHint)
def testInvertOr(self):
'''QFlags ~ (invert) operator over the result of an | (or) operator'''
- self.assertEqual(type(~(Qt.ItemIsSelectable | Qt.ItemIsEditable)), Qt.ItemFlags)
+ self.assertEqual(type(~(Qt.ItemFlag.ItemIsSelectable | Qt.ItemFlag.ItemIsEditable)),
+ Qt.ItemFlags)
def testEqual(self):
'''QFlags == operator'''
- flags = Qt.Window
- flags |= Qt.WindowMinimizeButtonHint
- flag_type = (flags & Qt.WindowType_Mask)
- self.assertEqual(flag_type, Qt.Window)
+ flags = Qt.WindowType.Window
+ flags |= Qt.WindowType.WindowMinimizeButtonHint
+ flag_type = (flags & Qt.WindowType.WindowType_Mask)
+ self.assertEqual(flag_type, Qt.WindowType.Window)
- self.assertEqual(Qt.KeyboardModifiers(Qt.ControlModifier), Qt.ControlModifier)
+ self.assertEqual(Qt.KeyboardModifiers(Qt.KeyboardModifier.ControlModifier),
+ Qt.KeyboardModifier.ControlModifier)
def testOperatorBetweenFlags(self):
'''QFlags & QFlags'''
- flags = Qt.NoItemFlags | Qt.ItemIsUserCheckable
- newflags = Qt.NoItemFlags | Qt.ItemIsUserCheckable
+ flags = Qt.ItemFlag.NoItemFlags | Qt.ItemFlag.ItemIsUserCheckable
+ newflags = Qt.ItemFlag.NoItemFlags | Qt.ItemFlag.ItemIsUserCheckable
self.assertTrue(flags & newflags)
def testOperatorDifferentOrder(self):
'''Different ordering of arguments'''
- flags = Qt.NoItemFlags | Qt.ItemIsUserCheckable
- self.assertEqual(flags | Qt.ItemIsEnabled, Qt.ItemIsEnabled | flags)
+ flags = Qt.ItemFlag.NoItemFlags | Qt.ItemFlag.ItemIsUserCheckable
+ self.assertEqual(flags | Qt.ItemFlag.ItemIsEnabled, Qt.ItemFlag.ItemIsEnabled | flags)
def testEqualNonNumericalObject(self):
'''QFlags ==,!= non-numerical object '''
- flags = Qt.NoItemFlags | Qt.ItemIsUserCheckable
+ flags = Qt.ItemFlag.NoItemFlags | Qt.ItemFlag.ItemIsUserCheckable
self.assertTrue(flags != None) # noqa: E711
self.assertFalse(flags == None) # noqa: E711
@@ -108,7 +116,7 @@ class QFlagOperatorTest(unittest.TestCase):
class QFlagsOnQVariant(unittest.TestCase):
def testQFlagsOnQVariant(self):
o = QObject()
- o.setProperty("foo", QIODevice.ReadOnly | QIODevice.WriteOnly)
+ o.setProperty("foo", QIODevice.OpenModeFlag.ReadOnly | QIODevice.OpenModeFlag.WriteOnly)
self.assertEqual(type(o.property("foo")), QIODevice.OpenMode)
diff --git a/sources/pyside6/tests/QtCore/qlinef_test.py b/sources/pyside6/tests/QtCore/qlinef_test.py
index 7c9e668df..40df326bd 100644
--- a/sources/pyside6/tests/QtCore/qlinef_test.py
+++ b/sources/pyside6/tests/QtCore/qlinef_test.py
@@ -24,7 +24,7 @@ class TestQLineF (unittest.TestCase):
tuple_ = l1.intersects(l2)
self.assertEqual(tuple, tuple_.__class__)
(value, p) = tuple_
- self.assertEqual(QLineF.BoundedIntersection, value)
+ self.assertEqual(QLineF.IntersectionType.BoundedIntersection, value)
self.assertEqual(QPointF(1, 0), p)
diff --git a/sources/pyside6/tests/QtCore/qlocale_test.py b/sources/pyside6/tests/QtCore/qlocale_test.py
index 6ad933d8f..8723cf000 100644
--- a/sources/pyside6/tests/QtCore/qlocale_test.py
+++ b/sources/pyside6/tests/QtCore/qlocale_test.py
@@ -20,36 +20,36 @@ from PySide6.QtCore import QLocale
class QLocaleTestToNumber(unittest.TestCase):
def testToNumberInt(self):
- obj = QLocale(QLocale.C)
+ obj = QLocale(QLocale.Language.C)
self.assertEqual((37, True), obj.toInt('37'))
def testToNumberFloat(self):
- obj = QLocale(QLocale.C)
+ obj = QLocale(QLocale.Language.C)
self.assertEqual((ctypes.c_float(37.109).value, True),
obj.toFloat('37.109'))
def testToNumberDouble(self):
- obj = QLocale(QLocale.C)
+ obj = QLocale(QLocale.Language.C)
self.assertEqual((ctypes.c_double(37.109).value, True),
obj.toDouble('37.109'))
def testToNumberShort(self):
- obj = QLocale(QLocale.C)
+ obj = QLocale(QLocale.Language.C)
self.assertEqual((ctypes.c_short(37).value, True),
obj.toShort('37'))
def testToNumberLong(self):
- obj = QLocale(QLocale.C)
+ obj = QLocale(QLocale.Language.C)
self.assertEqual((ctypes.c_long(37).value, True),
obj.toLong('37'))
def testToNumberULongLong(self):
- obj = QLocale(QLocale.C)
+ obj = QLocale(QLocale.Language.C)
self.assertEqual((ctypes.c_ulonglong(37).value, True),
obj.toULongLong('37'))
def testToNumberULongLongNegative(self):
- obj = QLocale(QLocale.C)
+ obj = QLocale(QLocale.Language.C)
self.assertTrue(not obj.toULongLong('-37')[1])
def testToCurrencyString(self):
diff --git a/sources/pyside6/tests/QtCore/qmessageauthenticationcode_test.py b/sources/pyside6/tests/QtCore/qmessageauthenticationcode_test.py
index 92778a78b..685838e46 100644
--- a/sources/pyside6/tests/QtCore/qmessageauthenticationcode_test.py
+++ b/sources/pyside6/tests/QtCore/qmessageauthenticationcode_test.py
@@ -19,7 +19,8 @@ from PySide6.QtCore import QCryptographicHash, QMessageAuthenticationCode
class TestQMessageAuthenticationCode (unittest.TestCase):
def test(self):
- code = QMessageAuthenticationCode(QCryptographicHash.Sha1, bytes('bla', "UTF-8"))
+ code = QMessageAuthenticationCode(QCryptographicHash.Algorithm.Sha1,
+ bytes('bla', "UTF-8"))
result = code.result()
self.assertTrue(result.size() > 0)
print(result.toHex())
diff --git a/sources/pyside6/tests/QtCore/qmetaobject_test.py b/sources/pyside6/tests/QtCore/qmetaobject_test.py
index ff8ed859e..39b4f36a0 100644
--- a/sources/pyside6/tests/QtCore/qmetaobject_test.py
+++ b/sources/pyside6/tests/QtCore/qmetaobject_test.py
@@ -120,7 +120,7 @@ class qmetaobject_test(unittest.TestCase):
app = QCoreApplication() # noqa: F841
sender = SemaphoreSender()
receiver = SemaphoreReceiver()
- sender.signal.connect(receiver.receiverSlot, Qt.QueuedConnection)
+ sender.signal.connect(receiver.receiverSlot, Qt.ConnectionType.QueuedConnection)
sender.emitSignal()
while not receiver.semaphore:
QCoreApplication.processEvents()
diff --git a/sources/pyside6/tests/QtCore/qobject_parent_test.py b/sources/pyside6/tests/QtCore/qobject_parent_test.py
index 103a3eb03..1abc23181 100644
--- a/sources/pyside6/tests/QtCore/qobject_parent_test.py
+++ b/sources/pyside6/tests/QtCore/qobject_parent_test.py
@@ -116,19 +116,19 @@ class ParentCase(unittest.TestCase):
search_result = parent.findChild(QObject, nested_child_name)
self.assertTrue(search_result)
search_result = parent.findChild(QObject, nested_child_name,
- Qt.FindChildrenRecursively)
+ Qt.FindChildOption.FindChildrenRecursively)
self.assertTrue(search_result)
search_result = parent.findChild(QObject, nested_child_name,
- Qt.FindDirectChildrenOnly)
+ Qt.FindChildOption.FindDirectChildrenOnly)
self.assertFalse(search_result)
search_results = parent.findChildren(QObject, nested_child_name)
self.assertEqual(len(search_results), 1)
search_result = parent.findChildren(QObject, nested_child_name,
- Qt.FindChildrenRecursively)
+ Qt.FindChildOption.FindChildrenRecursively)
self.assertEqual(len(search_results), 1)
search_results = parent.findChildren(QObject, nested_child_name,
- Qt.FindDirectChildrenOnly)
+ Qt.FindChildOption.FindDirectChildrenOnly)
self.assertEqual(len(search_results), 0)
def testFindChildWithoutName(self):
diff --git a/sources/pyside6/tests/QtCore/qobject_test.py b/sources/pyside6/tests/QtCore/qobject_test.py
index 176ab34b8..8a20f0500 100644
--- a/sources/pyside6/tests/QtCore/qobject_test.py
+++ b/sources/pyside6/tests/QtCore/qobject_test.py
@@ -76,8 +76,8 @@ class ObjectNameCase(unittest.TestCase):
obj = Obj()
# On first connect, UniqueConnection returns True, and on the second
# it must return False, and not a RuntimeError (PYSIDE-34)
- self.assertTrue(obj.signal.connect(obj.empty, Qt.UniqueConnection))
- self.assertFalse(obj.signal.connect(obj.empty, Qt.UniqueConnection))
+ self.assertTrue(obj.signal.connect(obj.empty, Qt.ConnectionType.UniqueConnection))
+ self.assertFalse(obj.signal.connect(obj.empty, Qt.ConnectionType.UniqueConnection))
def testDisconnect(self):
obj = Obj()
diff --git a/sources/pyside6/tests/QtCore/qprocess_test.py b/sources/pyside6/tests/QtCore/qprocess_test.py
index 6466b8575..1e69a15cb 100644
--- a/sources/pyside6/tests/QtCore/qprocess_test.py
+++ b/sources/pyside6/tests/QtCore/qprocess_test.py
@@ -30,7 +30,7 @@ class TestQProcess (unittest.TestCase):
pid = p.processId()
# We can't test the pid method result because it returns 0 when the
# process isn't running
- if p.state() == QProcess.Running:
+ if p.state() == QProcess.ProcessState.Running:
self.assertNotEqual(pid, 0)
p.waitForFinished()
else:
diff --git a/sources/pyside6/tests/QtCore/qresource_test.py b/sources/pyside6/tests/QtCore/qresource_test.py
index 7c3397c94..136d58025 100644
--- a/sources/pyside6/tests/QtCore/qresource_test.py
+++ b/sources/pyside6/tests/QtCore/qresource_test.py
@@ -33,7 +33,7 @@ class ResourcesUsage(unittest.TestCase):
orig.remove(carriage_return, 1)
f = QFile(':/quote.txt') # |QIODevice.Text
- self.assertTrue(f.open(QIODevice.ReadOnly), f.errorString())
+ self.assertTrue(f.open(QIODevice.OpenModeFlag.ReadOnly), f.errorString())
copy = f.readAll()
f.close()
self.assertEqual(orig, copy)
@@ -45,7 +45,7 @@ class ResourcesUsage(unittest.TestCase):
orig = file.read_bytes()
f = QFile(':/sample.png')
- self.assertTrue(f.open(QIODevice.ReadOnly), f.errorString())
+ self.assertTrue(f.open(QIODevice.OpenModeFlag.ReadOnly), f.errorString())
copy = f.readAll()
f.close()
self.assertEqual(len(orig), len(copy))
diff --git a/sources/pyside6/tests/QtCore/qsettings_test.py b/sources/pyside6/tests/QtCore/qsettings_test.py
index 5f86c9fbb..e40830d4c 100644
--- a/sources/pyside6/tests/QtCore/qsettings_test.py
+++ b/sources/pyside6/tests/QtCore/qsettings_test.py
@@ -22,7 +22,7 @@ class TestQSettings(unittest.TestCase):
file = Path(__file__).resolve().parent / 'qsettings_test.ini'
self.assertTrue(file.is_file())
file_path = QDir.fromNativeSeparators(os.fspath(file))
- settings = QSettings(file_path, QSettings.IniFormat)
+ settings = QSettings(file_path, QSettings.Format.IniFormat)
r = settings.value('var1')
self.assertEqual(type(r), list)
@@ -51,7 +51,7 @@ class TestQSettings(unittest.TestCase):
dir = QTemporaryDir(f'{temp_dir}/qsettings_XXXXXX')
self.assertTrue(dir.isValid())
file_name = dir.filePath('foo.ini')
- settings = QSettings(file_name, QSettings.IniFormat)
+ settings = QSettings(file_name, QSettings.Format.IniFormat)
sample_list = ["a", "b"]
string_list_of_empty = [""]
settings.setValue('zero_value', 0)
@@ -65,7 +65,7 @@ class TestQSettings(unittest.TestCase):
gc.collect()
# Loading values already set
- settings = QSettings(file_name, QSettings.IniFormat)
+ settings = QSettings(file_name, QSettings.Format.IniFormat)
# Getting value that doesn't exist
r = settings.value("variable")
diff --git a/sources/pyside6/tests/QtCore/qsocketnotifier_test.py b/sources/pyside6/tests/QtCore/qsocketnotifier_test.py
index beb90314a..33e58541f 100644
--- a/sources/pyside6/tests/QtCore/qsocketnotifier_test.py
+++ b/sources/pyside6/tests/QtCore/qsocketnotifier_test.py
@@ -20,14 +20,14 @@ from PySide6.QtCore import QCoreApplication, QSocketNotifier
class QSocketNotifierTest(unittest.TestCase):
def testClass(self):
- app = QCoreApplication([])
+ app = QCoreApplication([]) # noqa: F841
# socketpair is not available on Windows
if os.name != "nt":
w_sock, r_sock = socket.socketpair(socket.AF_UNIX, socket.SOCK_STREAM)
self.assertIsInstance(r_sock.fileno(), int)
- notifier = QSocketNotifier(r_sock.fileno(), QSocketNotifier.Read)
+ notifier = QSocketNotifier(r_sock.fileno(), QSocketNotifier.Type.Read)
self.assertIsNotNone(notifier)
diff --git a/sources/pyside6/tests/QtCore/qsysinfo_test.py b/sources/pyside6/tests/QtCore/qsysinfo_test.py
index 71a39bb5d..88279428d 100644
--- a/sources/pyside6/tests/QtCore/qsysinfo_test.py
+++ b/sources/pyside6/tests/QtCore/qsysinfo_test.py
@@ -17,12 +17,12 @@ from PySide6.QtCore import QSysInfo
class TestQSysInfo(unittest.TestCase):
def testEnumEndian(self):
- self.assertEqual(QSysInfo.BigEndian.value, 0)
- self.assertEqual(QSysInfo.LittleEndian.value, 1)
- self.assertTrue(QSysInfo.ByteOrder.value > -1)
+ self.assertEqual(QSysInfo.Endian.BigEndian.value, 0)
+ self.assertEqual(QSysInfo.Endian.LittleEndian.value, 1)
+ self.assertTrue(QSysInfo.Endian.ByteOrder.value > -1)
def testEnumSizes(self):
- self.assertTrue(QSysInfo.WordSize.value > 0)
+ self.assertTrue(QSysInfo.Sizes.WordSize.value > 0)
if __name__ == '__main__':
diff --git a/sources/pyside6/tests/QtCore/qtextstream_test.py b/sources/pyside6/tests/QtCore/qtextstream_test.py
index 99aae2187..2364970ba 100644
--- a/sources/pyside6/tests/QtCore/qtextstream_test.py
+++ b/sources/pyside6/tests/QtCore/qtextstream_test.py
@@ -20,8 +20,8 @@ class QTextStreamShiftTest(unittest.TestCase):
def setUp(self):
self.ba = QByteArray()
- self.read = QTextStream(self.ba, QIODevice.ReadOnly)
- self.write = QTextStream(self.ba, QIODevice.WriteOnly)
+ self.read = QTextStream(self.ba, QIODevice.OpenModeFlag.ReadOnly)
+ self.write = QTextStream(self.ba, QIODevice.OpenModeFlag.WriteOnly)
def testNumber(self):
'''QTextStream << number'''
@@ -84,7 +84,8 @@ class QTextStreamReadLinesFromDevice(unittest.TestCase):
data.append((QByteArray(bytes('ole', "UTF-8")), ['ole']))
data.append((QByteArray(bytes('ole\n', "UTF-8")), ['ole']))
data.append((QByteArray(bytes('ole\r\n', "UTF-8")), ['ole']))
- data.append((QByteArray(bytes('ole\r\ndole\r\ndoffen', "UTF-8")), ['ole', 'dole', 'doffen']))
+ data.append((QByteArray(bytes('ole\r\ndole\r\ndoffen', "UTF-8")),
+ ['ole', 'dole', 'doffen']))
self._check_data(data)
diff --git a/sources/pyside6/tests/QtCore/qtimezone_test.py b/sources/pyside6/tests/QtCore/qtimezone_test.py
index 3bfadc662..8fa36dda4 100644
--- a/sources/pyside6/tests/QtCore/qtimezone_test.py
+++ b/sources/pyside6/tests/QtCore/qtimezone_test.py
@@ -20,7 +20,8 @@ class TestQTimeZone (unittest.TestCase):
timeZone = QTimeZone(id)
self.assertTrue(timeZone.isValid())
self.assertEqual(timeZone.id(), id)
- name = timeZone.displayName(QTimeZone.GenericTime, QTimeZone.DefaultName)
+ name = timeZone.displayName(QTimeZone.TimeType.GenericTime,
+ QTimeZone.NameType.DefaultName)
self.assertTrue(name)
diff --git a/sources/pyside6/tests/QtCore/repr_test.py b/sources/pyside6/tests/QtCore/repr_test.py
index 3fe0d3216..084b69f87 100644
--- a/sources/pyside6/tests/QtCore/repr_test.py
+++ b/sources/pyside6/tests/QtCore/repr_test.py
@@ -46,7 +46,7 @@ class QTimeReprCopy(ReprCopyHelper, unittest.TestCase):
class QDateTimeReprCopy(ReprCopyHelper, unittest.TestCase):
def setUp(self):
- self.original = QDateTime(2010, 5, 18, 10, 24, 45, 223, Qt.LocalTime)
+ self.original = QDateTime(2010, 5, 18, 10, 24, 45, 223, Qt.TimeSpec.LocalTime)
class QSizeReprCopy(ReprCopyHelper, unittest.TestCase):
diff --git a/sources/pyside6/tests/QtCore/signal_sender.py b/sources/pyside6/tests/QtCore/signal_sender.py
index bcefe835e..522603bfa 100644
--- a/sources/pyside6/tests/QtCore/signal_sender.py
+++ b/sources/pyside6/tests/QtCore/signal_sender.py
@@ -82,7 +82,7 @@ class TestConstructorConnection(UsesQApplication):
model = QStringListModel(data_list,
destroyed=destroyed_handler,
dataChanged=changed_handler)
- model.setData(model.index(0, 0), "bla", Qt.EditRole)
+ model.setData(model.index(0, 0), "bla", Qt.ItemDataRole.EditRole)
del model
# PYSIDE-535: Need to collect garbage twice in PyPy to trigger deletion
gc.collect()
diff --git a/sources/pyside6/tests/QtGui/bug_493.py b/sources/pyside6/tests/QtGui/bug_493.py
index faf265755..9f94042ad 100644
--- a/sources/pyside6/tests/QtGui/bug_493.py
+++ b/sources/pyside6/tests/QtGui/bug_493.py
@@ -20,10 +20,10 @@ class TestBug493(unittest.TestCase):
def testIt(self):
# We need a qapp otherwise Qt will crash when trying to detect the
# current platform
- app = QGuiApplication([])
- ev1 = QKeyEvent(QEvent.KeyRelease, Qt.Key_Delete, Qt.NoModifier)
- ev2 = QKeyEvent(QEvent.KeyRelease, Qt.Key_Copy, Qt.NoModifier)
- ks = QKeySequence.Delete
+ app = QGuiApplication([]) # noqa: F841
+ ev1 = QKeyEvent(QEvent.Type.KeyRelease, Qt.Key.Key_Delete, Qt.KeyboardModifier.NoModifier)
+ ev2 = QKeyEvent(QEvent.Type.KeyRelease, Qt.Key.Key_Copy, Qt.KeyboardModifier.NoModifier)
+ ks = QKeySequence.StandardKey.Delete
self.assertTrue(ev1.matches(ks))
self.assertFalse(ev2.matches(ks))
diff --git a/sources/pyside6/tests/QtGui/bug_617.py b/sources/pyside6/tests/QtGui/bug_617.py
index fb793e6ee..505e068dc 100644
--- a/sources/pyside6/tests/QtGui/bug_617.py
+++ b/sources/pyside6/tests/QtGui/bug_617.py
@@ -24,7 +24,7 @@ class Bug617(unittest.TestCase):
def testRepr(self):
c = QColor.fromRgb(1, 2, 3, 4)
s = c.spec()
- self.assertEqual(repr(s), repr(QColor.Rgb))
+ self.assertEqual(repr(s), repr(QColor.Spec.Rgb))
def testOutOfBounds(self):
e = MyEvent()
diff --git a/sources/pyside6/tests/QtGui/bug_740.py b/sources/pyside6/tests/QtGui/bug_740.py
index c1b41c2ab..e5b80cbf8 100644
--- a/sources/pyside6/tests/QtGui/bug_740.py
+++ b/sources/pyside6/tests/QtGui/bug_740.py
@@ -18,8 +18,9 @@ from PySide6.QtGui import QBitmap, QImage
class TestQBitmap(UsesQApplication):
def testFromDataMethod(self):
- dataBits = bytes('\x38\x28\x38\x10\x10\x10\x10\x10\x10\x10\x10\x10\x10\x10\x10\x10\x10\x10\x10\x10\x10\x10\x10\x10\x10\x10\x10\x10\x10\x10\x10\x10\x10\x10\x10\x10\x10\x10\x10\x10\xfe\xfe\x7c\x7c\x38\x38\x10\x10', "UTF-8")
- bim = QBitmap.fromData(QSize(8, 48), dataBits, QImage.Format_Mono) # missing function
+ dataBits = bytes('\x38\x28\x38\x10\x10\x10\x10\x10\x10\x10\x10\x10\x10\x10\x10\x10\x10\x10\x10\x10\x10\x10\x10\x10\x10\x10\x10\x10\x10\x10\x10\x10\x10\x10\x10\x10\x10\x10\x10\x10\xfe\xfe\x7c\x7c\x38\x38\x10\x10', "UTF-8") # noqa: E501
+ # missing function
+ bim = QBitmap.fromData(QSize(8, 48), dataBits, QImage.Format.Format_Mono) # noqa: F841
if __name__ == '__main__':
diff --git a/sources/pyside6/tests/QtGui/event_filter_test.py b/sources/pyside6/tests/QtGui/event_filter_test.py
index ff894dbd0..57f137fdf 100644
--- a/sources/pyside6/tests/QtGui/event_filter_test.py
+++ b/sources/pyside6/tests/QtGui/event_filter_test.py
@@ -18,7 +18,7 @@ from PySide6.QtGui import QWindow
class MyFilter(QObject):
def eventFilter(self, obj, event):
- if event.type() == QEvent.KeyPress:
+ if event.type() == QEvent.Type.KeyPress:
pass
return QObject.eventFilter(self, obj, event)
diff --git a/sources/pyside6/tests/QtGui/float_to_int_implicit_conversion_test.py b/sources/pyside6/tests/QtGui/float_to_int_implicit_conversion_test.py
index e26d43254..0ed7fe402 100644
--- a/sources/pyside6/tests/QtGui/float_to_int_implicit_conversion_test.py
+++ b/sources/pyside6/tests/QtGui/float_to_int_implicit_conversion_test.py
@@ -26,7 +26,7 @@ class SetPixelFloat(UsesQApplication):
# Acquire resources
super(SetPixelFloat, self).setUp()
self.color = qRgb(255, 0, 0)
- self.image = QImage(200, 200, QImage.Format_RGB32)
+ self.image = QImage(200, 200, QImage.Format.Format_RGB32)
def tearDown(self):
# Release resources
diff --git a/sources/pyside6/tests/QtGui/qbrush_test.py b/sources/pyside6/tests/QtGui/qbrush_test.py
index 997ffc152..15c575d30 100644
--- a/sources/pyside6/tests/QtGui/qbrush_test.py
+++ b/sources/pyside6/tests/QtGui/qbrush_test.py
@@ -28,8 +28,8 @@ class Constructor(UsesQApplication):
obj = QBrush(color)
self.assertEqual(obj.color(), color)
- obj = QBrush(Qt.blue)
- self.assertEqual(obj.color(), Qt.blue)
+ obj = QBrush(Qt.GlobalColor.blue)
+ self.assertEqual(obj.color(), Qt.GlobalColor.blue)
def testGradient(self):
"""Test type discovery on class hierarchies with non-virtual
diff --git a/sources/pyside6/tests/QtGui/qcolor_test.py b/sources/pyside6/tests/QtGui/qcolor_test.py
index ba9cc5cb8..b1576b6f3 100644
--- a/sources/pyside6/tests/QtGui/qcolor_test.py
+++ b/sources/pyside6/tests/QtGui/qcolor_test.py
@@ -64,7 +64,7 @@ class QColorEqualGlobalColor(unittest.TestCase):
def testEqualGlobalColor(self):
'''QColor == Qt::GlobalColor'''
- self.assertEqual(QColor(255, 0, 0), Qt.red)
+ self.assertEqual(QColor(255, 0, 0), Qt.GlobalColor.red)
class QColorCopy(unittest.TestCase):
diff --git a/sources/pyside6/tests/QtGui/qdatastream_gui_operators_test.py b/sources/pyside6/tests/QtGui/qdatastream_gui_operators_test.py
index 8de7160e9..9fea56203 100644
--- a/sources/pyside6/tests/QtGui/qdatastream_gui_operators_test.py
+++ b/sources/pyside6/tests/QtGui/qdatastream_gui_operators_test.py
@@ -25,11 +25,11 @@ class QPixmapQDatastream(UsesQApplication):
self.source_pixmap = QPixmap(100, 100)
# PYSIDE-1533: Use Qt.transparent to force Format_ARGB32_Premultiplied
# when converting to QImage in any case.
- self.source_pixmap.fill(Qt.transparent)
+ self.source_pixmap.fill(Qt.GlobalColor.transparent)
self.output_pixmap = QPixmap()
self.buffer = QByteArray()
- self.read_stream = QDataStream(self.buffer, QIODevice.ReadOnly)
- self.write_stream = QDataStream(self.buffer, QIODevice.WriteOnly)
+ self.read_stream = QDataStream(self.buffer, QIODevice.OpenModeFlag.ReadOnly)
+ self.write_stream = QDataStream(self.buffer, QIODevice.OpenModeFlag.WriteOnly)
def testStream(self):
self.write_stream << self.source_pixmap
@@ -38,7 +38,7 @@ class QPixmapQDatastream(UsesQApplication):
image = self.output_pixmap.toImage()
pixel = image.pixel(10, 10)
- self.assertEqual(pixel, QColor(Qt.transparent).rgba())
+ self.assertEqual(pixel, QColor(Qt.GlobalColor.transparent).rgba())
self.assertEqual(self.source_pixmap.toImage(), image)
diff --git a/sources/pyside6/tests/QtGui/qfontmetrics_test.py b/sources/pyside6/tests/QtGui/qfontmetrics_test.py
index 257a3dae3..0de7fe830 100644
--- a/sources/pyside6/tests/QtGui/qfontmetrics_test.py
+++ b/sources/pyside6/tests/QtGui/qfontmetrics_test.py
@@ -42,49 +42,52 @@ class BoundingRectTest(QFontMetricsTest):
def testIntDefault(self):
'''QFontMetrics.boundingRect(int, int, int, int, ...) - default args'''
rect = self.metrics.boundingRect(0, 0, 0, 0,
- Qt.TextExpandTabs | Qt.AlignLeft,
- 'PySide by INdT')
+ Qt.TextFlag.TextExpandTabs | Qt.AlignmentFlag.AlignLeft,
+ 'PySide by Qt Company')
self.assertTrue(isinstance(rect, QRect))
def testIntWithArg(self):
'''QFontMetrics.boundingRect(int, int, int, int, ...) - single arg'''
rect = self.metrics.boundingRect(0, 0, 0, 0,
- Qt.TextExpandTabs | Qt.AlignLeft,
- 'PySide by INdT', 2)
+ Qt.TextFlag.TextExpandTabs | Qt.AlignmentFlag.AlignLeft,
+ 'PySide by Qt Company', 2)
self.assertTrue(isinstance(rect, QRect))
def testIntWithFull(self):
'''QFontMetrics.boundingRect(int, int, int, int, ...) - all argss'''
rect = self.metrics.boundingRect(0, 0, 0, 0,
- Qt.TextExpandTabs | Qt.AlignLeft,
- 'PySide by INdT', 20, [1, 2, 3, 4, 5])
+ Qt.TextFlag.TextExpandTabs | Qt.AlignmentFlag.AlignLeft,
+ 'PySide by Qt Company', 20, [1, 2, 3, 4, 5])
self.assertTrue(isinstance(rect, QRect))
def testIntTypeError(self):
'''QFontMetrics.boundingRect(int, int, int, int, ...) - type error'''
self.assertRaises(TypeError, self.metrics.boundingRect, 0, 0, 0, 0,
- Qt.TextExpandTabs | Qt.AlignLeft,
- 'PySide by INdT', 20, ['aaaa', 'ase'])
+ Qt.TextFlag.TextExpandTabs | Qt.AlignmentFlag.AlignLeft,
+ 'PySide by Qt Company', 20, ['aaaa', 'ase'])
def testQRectDefault(self):
'''QFontMetrics.boundingRect(QRect, ...) - default args'''
arg = QRect(0, 0, 100, 200)
- rect = self.metrics.boundingRect(arg, Qt.TextExpandTabs | Qt.AlignLeft,
- 'PySide by INdT')
+ rect = self.metrics.boundingRect(arg,
+ Qt.TextFlag.TextExpandTabs | Qt.AlignmentFlag.AlignLeft,
+ 'PySide by Qt Company')
self.assertTrue(isinstance(rect, QRect))
def testQRectWithArg(self):
'''QFontMetrics.boundingRect(QRect, ...) - only tabstops'''
arg = QRect(0, 0, 100, 200)
- rect = self.metrics.boundingRect(arg, Qt.TextExpandTabs | Qt.AlignLeft,
- 'PySide by INdT', 2)
+ rect = self.metrics.boundingRect(arg,
+ Qt.TextFlag.TextExpandTabs | Qt.AlignmentFlag.AlignLeft,
+ 'PySide by Qt Company', 2)
self.assertTrue(isinstance(rect, QRect))
def testQRectWithFull(self):
'''QFontMetrics.boundingRect(QRect, ...) - all arguments'''
arg = QRect(0, 0, 100, 200)
- rect = self.metrics.boundingRect(arg, Qt.TextExpandTabs | Qt.AlignLeft,
- 'PySide by INdT', 20,
+ rect = self.metrics.boundingRect(arg,
+ Qt.TextFlag.TextExpandTabs | Qt.AlignmentFlag.AlignLeft,
+ 'PySide by Qt Company', 20,
[1, 2, 3, 4, 5])
self.assertTrue(isinstance(rect, QRect))
@@ -92,8 +95,8 @@ class BoundingRectTest(QFontMetricsTest):
'''QFontMetrics.boundingRect(QRect, ...) - type error'''
arg = QRect(0, 0, 100, 200)
self.assertRaises(TypeError, self.metrics.boundingRect, arg,
- Qt.TextExpandTabs | Qt.AlignLeft,
- 'PySide by INdT', 20, ['aaaa', 'ase'])
+ Qt.TextFlag.TextExpandTabs | Qt.AlignmentFlag.AlignLeft,
+ 'PySide by Qt Company', 20, ['aaaa', 'ase'])
class SizeTest(QFontMetricsTest):
@@ -101,27 +104,27 @@ class SizeTest(QFontMetricsTest):
def testDefault(self):
'''QFontMetrics.size - default arguments'''
- size = self.metrics.size(Qt.TextExpandTabs | Qt.TextSingleLine,
- 'PySide by INdT')
+ size = self.metrics.size(Qt.TextFlag.TextExpandTabs | Qt.TextFlag.TextSingleLine,
+ 'PySide by Qt Company')
self.assertTrue(isinstance(size, QSize))
def testWithTabStops(self):
'''QFontMetrics.size - only tabstops'''
- size = self.metrics.size(Qt.TextExpandTabs | Qt.TextSingleLine,
- 'PySide by INdT', 2)
+ size = self.metrics.size(Qt.TextFlag.TextExpandTabs | Qt.TextFlag.TextSingleLine,
+ 'PySide by Qt Company', 2)
self.assertTrue(isinstance(size, QSize))
def testFull(self):
'''QFontMetrics.size - all arguments'''
- size = self.metrics.size(Qt.TextExpandTabs | Qt.TextSingleLine,
- 'PySide by INdT', 2, [1, 2, 3, 4])
+ size = self.metrics.size(Qt.TextFlag.TextExpandTabs | Qt.TextFlag.TextSingleLine,
+ 'PySide by Qt Company', 2, [1, 2, 3, 4])
self.assertTrue(isinstance(size, QSize))
def testTypeError(self):
'''QFontMetrics.size - type error'''
self.assertRaises(TypeError, self.metrics.size,
- Qt.TextExpandTabs | Qt.AlignLeft,
- 'PySide by INdT', 20, ['aaaa', 'ase'])
+ Qt.TextFlag.TextExpandTabs | Qt.AlignmentFlag.AlignLeft,
+ 'PySide by Qt Company', 20, ['aaaa', 'ase'])
class QFontMetricsFTest(UsesQApplication):
@@ -146,22 +149,25 @@ class FBoundingRectTest(QFontMetricsFTest):
def testQRectDefault(self):
'''QFontMetricsF.boundingRect(QRectF, ...) - default args'''
arg = QRectF(0, 0, 100, 200)
- rect = self.metrics.boundingRect(arg, Qt.TextExpandTabs | Qt.AlignLeft,
- 'PySide by INdT')
+ rect = self.metrics.boundingRect(arg,
+ Qt.TextFlag.TextExpandTabs | Qt.AlignmentFlag.AlignLeft,
+ 'PySide by Qt Company')
self.assertTrue(isinstance(rect, QRectF))
def testQRectWithArg(self):
'''QFontMetricsF.boundingRect(QRectF, ...) - only tabstops'''
arg = QRectF(0, 0, 100, 200)
- rect = self.metrics.boundingRect(arg, Qt.TextExpandTabs | Qt.AlignLeft,
- 'PySide by INdT', 2)
+ rect = self.metrics.boundingRect(arg,
+ Qt.TextFlag.TextExpandTabs | Qt.AlignmentFlag.AlignLeft,
+ 'PySide by Qt Company', 2)
self.assertTrue(isinstance(rect, QRectF))
def testQRectWithFull(self):
'''QFontMetricsF.boundingRect(QRectF, ...) - all arguments'''
arg = QRectF(0, 0, 100, 200)
- rect = self.metrics.boundingRect(arg, Qt.TextExpandTabs | Qt.AlignLeft,
- 'PySide by INdT', 20,
+ rect = self.metrics.boundingRect(arg,
+ Qt.TextFlag.TextExpandTabs | Qt.AlignmentFlag.AlignLeft,
+ 'PySide by Qt Company', 20,
[1, 2, 3, 4, 5])
self.assertTrue(isinstance(rect, QRectF))
@@ -169,8 +175,8 @@ class FBoundingRectTest(QFontMetricsFTest):
'''QFontMetricsF.boundingRect(QRectF, ...) - type error'''
arg = QRectF(0, 0, 100, 200)
self.assertRaises(TypeError, self.metrics.boundingRect, arg,
- Qt.TextExpandTabs | Qt.AlignLeft,
- 'PySide by INdT', 20, ['aaaa', 'ase'])
+ Qt.TextFlag.TextExpandTabs | Qt.AlignmentFlag.AlignLeft,
+ 'PySide by Qt Company', 20, ['aaaa', 'ase'])
class FSizeTest(QFontMetricsFTest):
@@ -178,27 +184,27 @@ class FSizeTest(QFontMetricsFTest):
def testDefault(self):
'''QFontMetricsF.size - default arguments'''
- size = self.metrics.size(Qt.TextExpandTabs | Qt.TextSingleLine,
- 'PySide by INdT')
+ size = self.metrics.size(Qt.TextFlag.TextExpandTabs | Qt.TextFlag.TextSingleLine,
+ 'PySide by Qt Company')
self.assertTrue(isinstance(size, QSizeF))
def testWithTabStops(self):
'''QFontMetricsF.size - only tabstops'''
- size = self.metrics.size(Qt.TextExpandTabs | Qt.TextSingleLine,
- 'PySide by INdT', 2)
+ size = self.metrics.size(Qt.TextFlag.TextExpandTabs | Qt.TextFlag.TextSingleLine,
+ 'PySide by Qt Company', 2)
self.assertTrue(isinstance(size, QSizeF))
def testFull(self):
'''QFontMetricsF.size - all arguments'''
- size = self.metrics.size(Qt.TextExpandTabs | Qt.TextSingleLine,
- 'PySide by INdT', 2, [1, 2, 3, 4])
+ size = self.metrics.size(Qt.TextFlag.TextExpandTabs | Qt.TextFlag.TextSingleLine,
+ 'PySide by Qt Company', 2, [1, 2, 3, 4])
self.assertTrue(isinstance(size, QSizeF))
def testTypeError(self):
'''QFontMetricsF.size - type error'''
self.assertRaises(TypeError, self.metrics.size,
- Qt.TextExpandTabs | Qt.AlignLeft,
- 'PySide by INdT', 20, ['aaaa', 'ase'])
+ Qt.TextFlag.TextExpandTabs | Qt.AlignmentFlag.AlignLeft,
+ 'PySide by Qt Company', 20, ['aaaa', 'ase'])
class QCharTest(QFontMetricsFTest):
diff --git a/sources/pyside6/tests/QtGui/qimage_test.py b/sources/pyside6/tests/QtGui/qimage_test.py
index c87cfcf4b..61fffc124 100644
--- a/sources/pyside6/tests/QtGui/qimage_test.py
+++ b/sources/pyside6/tests/QtGui/qimage_test.py
@@ -35,16 +35,16 @@ class QImageTest(UsesQApplication):
img2.setColorSpace(img0.colorSpace())
self.assertEqual(img0, img2)
- ## test scanLine method
+ # test scanLine method
data1 = img0.scanLine(0)
data2 = img1.scanLine(0)
self.assertEqual(data1, data2)
def testEmptyBuffer(self):
- img = QImage(bytes('', "UTF-8"), 100, 100, QImage.Format_ARGB32)
+ img = QImage(bytes('', "UTF-8"), 100, 100, QImage.Format.Format_ARGB32) # noqa: F841
def testEmptyStringAsBuffer(self):
- img = QImage(bytes('', "UTF-8"), 100, 100, QImage.Format_ARGB32)
+ img = QImage(bytes('', "UTF-8"), 100, 100, QImage.Format.Format_ARGB32) # noqa: F841
def testXpmConstructor(self):
img = QImage(xpm)
diff --git a/sources/pyside6/tests/QtGui/qimage_win_test.py b/sources/pyside6/tests/QtGui/qimage_win_test.py
index f8ceb4aa9..e7a09a72a 100644
--- a/sources/pyside6/tests/QtGui/qimage_win_test.py
+++ b/sources/pyside6/tests/QtGui/qimage_win_test.py
@@ -19,8 +19,8 @@ from helper.usesqapplication import UsesQApplication
def create_image():
- result = QImage(20, 20, QImage.Format_RGB32)
- result.fill(Qt.white)
+ result = QImage(20, 20, QImage.Format.Format_RGB32)
+ result.fill(Qt.GlobalColor.white)
return result
diff --git a/sources/pyside6/tests/QtGui/qkeysequence_test.py b/sources/pyside6/tests/QtGui/qkeysequence_test.py
index a6f3188d4..56e3a00ff 100644
--- a/sources/pyside6/tests/QtGui/qkeysequence_test.py
+++ b/sources/pyside6/tests/QtGui/qkeysequence_test.py
@@ -23,11 +23,12 @@ class QKeySequenceTest(UsesQApplication):
# bug #774
# PYSIDE-1735: Remapped from Qt.Modifier to Qt.KeyboardModifier
# Note that Qt.(Keyboard)?Modifier will be no longer IntFlag.
- ks = QKeySequence(Qt.ShiftModifier, Qt.ControlModifier, Qt.Key_P, Qt.Key_R)
- self.assertEqual(ks[0].keyboardModifiers(), Qt.ShiftModifier)
- self.assertEqual(ks[1].keyboardModifiers(), Qt.ControlModifier)
- self.assertEqual(ks[2].key(), Qt.Key_P)
- self.assertEqual(ks[3].key(), Qt.Key_R)
+ ks = QKeySequence(Qt.KeyboardModifier.ShiftModifier, Qt.KeyboardModifier.ControlModifier,
+ Qt.Key.Key_P, Qt.Key.Key_R)
+ self.assertEqual(ks[0].keyboardModifiers(), Qt.KeyboardModifier.ShiftModifier)
+ self.assertEqual(ks[1].keyboardModifiers(), Qt.KeyboardModifier.ControlModifier)
+ self.assertEqual(ks[2].key(), Qt.Key.Key_P)
+ self.assertEqual(ks[3].key(), Qt.Key.Key_R)
def testAutoMnemonic(self):
qt_set_sequence_auto_mnemonic(True)
diff --git a/sources/pyside6/tests/QtGui/qpainter_test.py b/sources/pyside6/tests/QtGui/qpainter_test.py
index e3ec66381..c304b83e8 100644
--- a/sources/pyside6/tests/QtGui/qpainter_test.py
+++ b/sources/pyside6/tests/QtGui/qpainter_test.py
@@ -27,7 +27,7 @@ except ModuleNotFoundError:
class QPainterDrawText(UsesQApplication):
def setUp(self):
super(QPainterDrawText, self).setUp()
- self.image = QImage(32, 32, QImage.Format_ARGB32)
+ self.image = QImage(32, 32, QImage.Format.Format_ARGB32)
self.painter = QPainter(self.image)
self.text = 'teste!'
@@ -42,14 +42,15 @@ class QPainterDrawText(UsesQApplication):
def testDrawText(self):
# bug #254
rect = self.painter.drawText(100, 100, 100, 100,
- Qt.AlignCenter | Qt.TextWordWrap,
+ Qt.AlignmentFlag.AlignCenter | Qt.TextFlag.TextWordWrap,
self.text)
self.assertTrue(isinstance(rect, QRect))
def testDrawTextWithRect(self):
# bug #225
rect = QRect(100, 100, 100, 100)
- newRect = self.painter.drawText(rect, Qt.AlignCenter | Qt.TextWordWrap,
+ newRect = self.painter.drawText(rect,
+ Qt.AlignmentFlag.AlignCenter | Qt.TextFlag.TextWordWrap,
self.text)
self.assertTrue(isinstance(newRect, QRect))
@@ -57,7 +58,8 @@ class QPainterDrawText(UsesQApplication):
def testDrawTextWithRectF(self):
'''QPainter.drawText(QRectF, ... ,QRectF*) inject code'''
rect = QRectF(100, 52.3, 100, 100)
- newRect = self.painter.drawText(rect, Qt.AlignCenter | Qt.TextWordWrap,
+ newRect = self.painter.drawText(rect,
+ Qt.AlignmentFlag.AlignCenter | Qt.TextFlag.TextWordWrap,
self.text)
self.assertTrue(isinstance(newRect, QRectF))
@@ -105,7 +107,7 @@ class SetBrushWithOtherArgs(UsesQApplication):
'''Using qpainter.setBrush with args other than QBrush'''
def testSetBrushGradient(self):
- image = QImage(32, 32, QImage.Format_ARGB32)
+ image = QImage(32, 32, QImage.Format.Format_ARGB32)
with QPainter(image) as painter:
gradient = QLinearGradient(0, 0, 0, 0)
painter.setBrush(gradient)
diff --git a/sources/pyside6/tests/QtGui/qpdfwriter_test.py b/sources/pyside6/tests/QtGui/qpdfwriter_test.py
index 1379f8e80..2b1549384 100644
--- a/sources/pyside6/tests/QtGui/qpdfwriter_test.py
+++ b/sources/pyside6/tests/QtGui/qpdfwriter_test.py
@@ -22,7 +22,9 @@ class QPdfWriterTest(UsesQApplication):
temporaryFile = QTemporaryFile(QDir.tempPath() + "/pdfwriter_test_XXXXXX.pdf")
self.assertTrue(temporaryFile.open())
pdfWriter = QPdfWriter(temporaryFile)
- pdfWriter.setPageLayout(QPageLayout(QPageSize(QPageSize.A4), QPageLayout.Portrait, QMarginsF(10, 10, 10, 10)))
+ pdfWriter.setPageLayout(QPageLayout(QPageSize(QPageSize.PageSizeId.A4),
+ QPageLayout.Orientation.Portrait,
+ QMarginsF(10, 10, 10, 10)))
doc = QTextDocument("Some text")
doc.print_(pdfWriter)
temporaryFile.close()
diff --git a/sources/pyside6/tests/QtGui/qpen_test.py b/sources/pyside6/tests/QtGui/qpen_test.py
index a3328c2e7..1a187c1ed 100644
--- a/sources/pyside6/tests/QtGui/qpen_test.py
+++ b/sources/pyside6/tests/QtGui/qpen_test.py
@@ -25,9 +25,9 @@ class Painting(QRasterWindow):
def paintEvent(self, event):
with QPainter(self) as painter:
- painter.setPen(Qt.NoPen)
+ painter.setPen(Qt.PenStyle.NoPen)
self.penFromEnum = painter.pen()
- intVal = Qt.NoPen.value
+ intVal = Qt.PenStyle.NoPen.value
painter.setPen(intVal)
self.penFromInteger = painter.pen()
QTimer.singleShot(20, self.close)
@@ -41,7 +41,7 @@ class QPenTest(UsesQApplication):
style = Qt.PenStyle(0)
cap = Qt.PenCapStyle(0)
join = Qt.PenJoinStyle(0)
- pen = QPen(Qt.blue, width, style, cap, join) # noqa: F841
+ pen = QPen(Qt.GlobalColor.blue, width, style, cap, join) # noqa: F841
def testSetPenWithPenStyleEnum(self):
'''Calls QPainter.setPen with both enum and integer. Bug #511.'''
@@ -49,8 +49,8 @@ class QPenTest(UsesQApplication):
w.show()
w.setTitle("qpen_test")
self.app.exec()
- self.assertEqual(w.penFromEnum.style(), Qt.NoPen)
- self.assertEqual(w.penFromInteger.style(), Qt.SolidLine)
+ self.assertEqual(w.penFromEnum.style(), Qt.PenStyle.NoPen)
+ self.assertEqual(w.penFromInteger.style(), Qt.PenStyle.SolidLine)
if __name__ == '__main__':
diff --git a/sources/pyside6/tests/QtGui/qpixelformat_test.py b/sources/pyside6/tests/QtGui/qpixelformat_test.py
index 32d34a577..f9239b255 100644
--- a/sources/pyside6/tests/QtGui/qpixelformat_test.py
+++ b/sources/pyside6/tests/QtGui/qpixelformat_test.py
@@ -20,8 +20,8 @@ from PySide6.QtGui import QColor, QImage, QPixelFormat, qPixelFormatRgba
class QPixelFormatTest(UsesQApplication):
def test(self):
- image = QImage(QSize(200, 200), QImage.Format_ARGB32)
- image.fill(QColor(Qt.red))
+ image = QImage(QSize(200, 200), QImage.Format.Format_ARGB32)
+ image.fill(QColor(Qt.GlobalColor.red))
pixelFormat = image.pixelFormat()
print(pixelFormat.greenSize())
self.assertEqual(pixelFormat.alphaSize(), 8)
@@ -31,9 +31,10 @@ class QPixelFormatTest(UsesQApplication):
self.assertEqual(pixelFormat.bitsPerPixel(), 32)
def testHelpers(self):
- format = qPixelFormatRgba(8, 8, 8, 8, QPixelFormat.UsesAlpha,
- QPixelFormat.AtBeginning, QPixelFormat.Premultiplied,
- QPixelFormat.UnsignedByte)
+ format = qPixelFormatRgba(8, 8, 8, 8, QPixelFormat.AlphaUsage.UsesAlpha,
+ QPixelFormat.AlphaPosition.AtBeginning,
+ QPixelFormat.AlphaPremultiplied.Premultiplied,
+ QPixelFormat.TypeInterpretation.UnsignedByte)
self.assertEqual(format.redSize(), 8)
diff --git a/sources/pyside6/tests/QtGui/qpixmap_test.py b/sources/pyside6/tests/QtGui/qpixmap_test.py
index 12be6d28c..0451b9839 100644
--- a/sources/pyside6/tests/QtGui/qpixmap_test.py
+++ b/sources/pyside6/tests/QtGui/qpixmap_test.py
@@ -37,7 +37,7 @@ class QPixmapTest(UsesQApplication):
def testQPixmapLoadFromDataWithQFile(self):
f = QFile(self._sample_file)
- self.assertTrue(f.open(QIODevice.ReadOnly))
+ self.assertTrue(f.open(QIODevice.OpenModeFlag.ReadOnly))
data = f.read(f.size())
f.close()
pixmap = QPixmap()
@@ -54,8 +54,9 @@ class QPixmapToImage(UsesQApplication):
def testFilledImage(self):
'''QPixmap.fill + toImage + image.pixel'''
+ red = QColor(Qt.GlobalColor.red)
pixmap = QPixmap(100, 200)
- pixmap.fill(Qt.red) # Default Qt.white
+ pixmap.fill(red) # Default Qt.GlobalColor.white
self.assertEqual(pixmap.height(), 200)
self.assertEqual(pixmap.width(), 100)
@@ -66,7 +67,7 @@ class QPixmapToImage(UsesQApplication):
self.assertEqual(image.width(), 100)
pixel = image.pixel(10, 10)
- self.assertEqual(pixel, QColor(Qt.red).rgba())
+ self.assertEqual(pixel, red.rgba())
if __name__ == '__main__':
diff --git a/sources/pyside6/tests/QtGui/qrasterwindow_test.py b/sources/pyside6/tests/QtGui/qrasterwindow_test.py
index 038ce8836..09fcd46e8 100644
--- a/sources/pyside6/tests/QtGui/qrasterwindow_test.py
+++ b/sources/pyside6/tests/QtGui/qrasterwindow_test.py
@@ -28,7 +28,7 @@ class StaticTextRasterWindow(QRasterWindow):
def paintEvent(self, event):
clientRect = QRect(QPoint(0, 0), self.size())
with QPainter(self) as painter:
- painter.fillRect(clientRect, QColor(Qt.red))
+ painter.fillRect(clientRect, QColor(Qt.GlobalColor.red))
painter.drawStaticText(QPoint(10, 10), self.text)
@@ -43,16 +43,16 @@ class TextDocumentWindow(QRasterWindow):
def paintEvent(self, event):
with QPainter(self) as painter:
clientRect = QRect(QPoint(0, 0), self.size())
- painter.fillRect(clientRect, QColor(Qt.white))
+ painter.fillRect(clientRect, QColor(Qt.GlobalColor.white))
ctx = QAbstractTextDocumentLayout.PaintContext()
ctx.clip = clientRect
sel = QAbstractTextDocumentLayout.Selection()
cursor = QTextCursor(self.m_document)
- cursor.movePosition(QTextCursor.Start)
- cursor.movePosition(QTextCursor.NextWord, QTextCursor.KeepAnchor)
+ cursor.movePosition(QTextCursor.MoveOperation.Start)
+ cursor.movePosition(QTextCursor.MoveOperation.NextWord, QTextCursor.MoveMode.KeepAnchor)
sel.cursor = cursor
- sel.format.setForeground(Qt.red)
+ sel.format.setForeground(Qt.GlobalColor.red)
ctx.selections = [sel]
self.m_document.documentLayout().draw(painter, ctx)
diff --git a/sources/pyside6/tests/QtGui/qshortcut_test.py b/sources/pyside6/tests/QtGui/qshortcut_test.py
index 91bf1cd18..b093a01a8 100644
--- a/sources/pyside6/tests/QtGui/qshortcut_test.py
+++ b/sources/pyside6/tests/QtGui/qshortcut_test.py
@@ -44,8 +44,8 @@ class QAppPresence(unittest.TestCase):
self.qapp = QGuiApplication([])
f = Foo()
- self.sc = MyShortcut(QKeySequence(Qt.Key_Return), f, f.slot_of_foo)
- self.scstd = MyShortcut(QKeySequence.Copy, f, f.slot_of_copy)
+ self.sc = MyShortcut(QKeySequence(Qt.Key.Key_Return), f, f.slot_of_foo)
+ self.scstd = MyShortcut(QKeySequence.StandardKey.Copy, f, f.slot_of_copy)
QTimer.singleShot(0, self.init)
self.qapp.exec()
self.assertEqual(f.ok, True)
diff --git a/sources/pyside6/tests/QtGui/qtextdocument_functions.py b/sources/pyside6/tests/QtGui/qtextdocument_functions.py
index 0350c93ac..7d4a85177 100644
--- a/sources/pyside6/tests/QtGui/qtextdocument_functions.py
+++ b/sources/pyside6/tests/QtGui/qtextdocument_functions.py
@@ -8,10 +8,10 @@ import unittest
from pathlib import Path
sys.path.append(os.fspath(Path(__file__).resolve().parents[1]))
-from init_paths import init_test_paths
+from init_paths import init_test_paths # noqa: E402
init_test_paths(False)
-from PySide6.QtGui import QPageRanges, Qt
+from PySide6.QtGui import QPageRanges, Qt # noqa: E402
class QTextDocumentFunctions(unittest.TestCase):
@@ -19,7 +19,7 @@ class QTextDocumentFunctions(unittest.TestCase):
def testFunctions(self):
self.assertFalse(Qt.mightBeRichText('bla'))
self.assertTrue(Qt.mightBeRichText('<html><head/><body><p>bla</p></body></html>'))
- html = Qt.convertFromPlainText("A & B", Qt.WhiteSpaceNormal)
+ html = Qt.convertFromPlainText("A & B", Qt.WhiteSpaceMode.WhiteSpaceNormal)
self.assertEqual(html, '<p>A &amp; B</p>')
diff --git a/sources/pyside6/tests/QtGui/qtextdocumentwriter_test.py b/sources/pyside6/tests/QtGui/qtextdocumentwriter_test.py
index b8401d960..5ca207794 100644
--- a/sources/pyside6/tests/QtGui/qtextdocumentwriter_test.py
+++ b/sources/pyside6/tests/QtGui/qtextdocumentwriter_test.py
@@ -21,7 +21,7 @@ class QTextDocumentWriterTest(unittest.TestCase):
text = 'foobar'
doc = QTextDocument(text)
b = QBuffer()
- b.open(QBuffer.ReadWrite)
+ b.open(QBuffer.OpenModeFlag.ReadWrite)
writer = QTextDocumentWriter(b, bytes("plaintext", "UTF-8"))
writer.write(doc)
b.close()
diff --git a/sources/pyside6/tests/QtGui/qtextline_test.py b/sources/pyside6/tests/QtGui/qtextline_test.py
index b8592526c..f9ecafd4d 100644
--- a/sources/pyside6/tests/QtGui/qtextline_test.py
+++ b/sources/pyside6/tests/QtGui/qtextline_test.py
@@ -31,7 +31,7 @@ class QTextLineTest(UsesQApplication):
def testTextOption(self):
"""PYSIDE-2088, large enum values causing MSVC issues."""
- v = QTextOption.IncludeTrailingSpaces | QTextOption.ShowTabsAndSpaces
+ v = QTextOption.Flag.IncludeTrailingSpaces | QTextOption.Flag.ShowTabsAndSpaces
self.assertEqual(v.value, 2147483649)
diff --git a/sources/pyside6/tests/QtNetwork/bug_446.py b/sources/pyside6/tests/QtNetwork/bug_446.py
index 861cff77b..869b06e83 100644
--- a/sources/pyside6/tests/QtNetwork/bug_446.py
+++ b/sources/pyside6/tests/QtNetwork/bug_446.py
@@ -43,7 +43,8 @@ class HttpSignalsCase(UsesQApplication):
self.assertTrue(self.server.listen())
self.client = QTcpSocket()
self.client.connected.connect(self.onClientConnect)
- self.client.connectToHost(QHostAddress(QHostAddress.LocalHost), self.server.serverPort())
+ self.client.connectToHost(QHostAddress(QHostAddress.SpecialAddress.LocalHost),
+ self.server.serverPort())
def done(self):
self.serverConnection.close()
diff --git a/sources/pyside6/tests/QtNetwork/dnslookup_test.py b/sources/pyside6/tests/QtNetwork/dnslookup_test.py
index d05f614fd..d138478a5 100644
--- a/sources/pyside6/tests/QtNetwork/dnslookup_test.py
+++ b/sources/pyside6/tests/QtNetwork/dnslookup_test.py
@@ -23,7 +23,7 @@ class DnsLookupTestCase(unittest.TestCase):
def setUp(self):
self._app = QCoreApplication([])
- self._lookup = QDnsLookup(QDnsLookup.ANY, 'www.qt.io')
+ self._lookup = QDnsLookup(QDnsLookup.Type.ANY, 'www.qt.io')
self._lookup.finished.connect(self._finished)
def tearDown(self):
@@ -32,7 +32,7 @@ class DnsLookupTestCase(unittest.TestCase):
gc.collect()
def _finished(self):
- if self._lookup.error() == QDnsLookup.NoError:
+ if self._lookup.error() == QDnsLookup.Error.NoError:
nameRecords = self._lookup.canonicalNameRecords()
if nameRecords:
print(nameRecords[0].name())
diff --git a/sources/pyside6/tests/QtNetwork/qhostinfo_test.py b/sources/pyside6/tests/QtNetwork/qhostinfo_test.py
index 19aac4f30..678646f37 100644
--- a/sources/pyside6/tests/QtNetwork/qhostinfo_test.py
+++ b/sources/pyside6/tests/QtNetwork/qhostinfo_test.py
@@ -36,7 +36,7 @@ class Receiver(QObject):
@Slot(QHostInfo)
def info_received(self, host_info):
name = host_info.hostName()
- if host_info.error() == QHostInfo.NoError:
+ if host_info.error() == QHostInfo.HostInfoError.NoError:
addresses = [a.toString() for a in host_info.addresses()]
addresses_str = ', '.join(addresses)
print(f'"{name}" resolved to {addresses_str}')
diff --git a/sources/pyside6/tests/QtNetwork/qpassworddigestor_test.py b/sources/pyside6/tests/QtNetwork/qpassworddigestor_test.py
index 87d3395ad..b0eecdbc6 100644
--- a/sources/pyside6/tests/QtNetwork/qpassworddigestor_test.py
+++ b/sources/pyside6/tests/QtNetwork/qpassworddigestor_test.py
@@ -20,7 +20,7 @@ from PySide6.QtNetwork import QPasswordDigestor
class TestPasswordDigestor(unittest.TestCase):
def test(self):
- b = QPasswordDigestor.deriveKeyPbkdf1(QCryptographicHash.Sha1,
+ b = QPasswordDigestor.deriveKeyPbkdf1(QCryptographicHash.Algorithm.Sha1,
b'test', b'saltnpep', 10, 20)
self.assertEqual(b.size(), 20)
diff --git a/sources/pyside6/tests/QtNetwork/udpsocket_test.py b/sources/pyside6/tests/QtNetwork/udpsocket_test.py
index 98fbe4043..4af8fccde 100644
--- a/sources/pyside6/tests/QtNetwork/udpsocket_test.py
+++ b/sources/pyside6/tests/QtNetwork/udpsocket_test.py
@@ -32,7 +32,7 @@ class HttpSignalsCase(unittest.TestCase):
self.socket = QUdpSocket()
self.server = QUdpSocket()
- self.server.bind(QHostAddress(QHostAddress.LocalHost), 45454)
+ self.server.bind(QHostAddress(QHostAddress.SpecialAddress.LocalHost), 45454)
def tearDown(self):
# Release resources
@@ -43,7 +43,7 @@ class HttpSignalsCase(unittest.TestCase):
gc.collect()
def sendPackage(self):
- addr = QHostAddress(QHostAddress.LocalHost)
+ addr = QHostAddress(QHostAddress.SpecialAddress.LocalHost)
self.socket.writeDatagram(bytes('datagram', "UTF-8"), addr, 45454)
def callback(self):
diff --git a/sources/pyside6/tests/QtOpenGL/qopenglbuffer_test.py b/sources/pyside6/tests/QtOpenGL/qopenglbuffer_test.py
index e73ae46c1..5146cc196 100644
--- a/sources/pyside6/tests/QtOpenGL/qopenglbuffer_test.py
+++ b/sources/pyside6/tests/QtOpenGL/qopenglbuffer_test.py
@@ -19,13 +19,13 @@ from PySide6.QtOpenGL import QOpenGLBuffer
def createSurface(surfaceClass):
- if surfaceClass == QSurface.Window:
+ if surfaceClass == QSurface.SurfaceClass.Window:
window = QWindow()
- window.setSurfaceType(QWindow.OpenGLSurface)
+ window.setSurfaceType(QWindow.SurfaceType.OpenGLSurface)
window.setGeometry(0, 0, 10, 10)
window.create()
return window
- elif surfaceClass == QSurface.Offscreen:
+ elif surfaceClass == QSurface.SurfaceClass.Offscreen:
# Create a window and get the format from that. For example, if an EGL
# implementation provides 565 and 888 configs for PBUFFER_BIT but only
# 888 for WINDOW_BIT, we may end up with a pbuffer surface that is
@@ -34,7 +34,7 @@ def createSurface(surfaceClass):
_format = QSurfaceFormat
if _format.redBufferSize() == -1:
window = QWindow()
- window.setSurfaceType(QWindow.OpenGLSurface)
+ window.setSurfaceType(QWindow.SurfaceType.OpenGLSurface)
window.setGeometry(0, 0, 10, 10)
window.create()
_format = window.format()
@@ -47,7 +47,7 @@ def createSurface(surfaceClass):
class QOpenGLBufferTest(UsesQApplication):
def testBufferCreate(self):
- surface = createSurface(QSurface.Window)
+ surface = createSurface(QSurface.SurfaceClass.Window)
ctx = QOpenGLContext()
ctx.create()
ctx.makeCurrent(surface)
@@ -59,7 +59,7 @@ class QOpenGLBufferTest(UsesQApplication):
self.assertTrue(buf.create())
self.assertTrue(buf.isCreated())
- self.assertEqual(buf.type(), QOpenGLBuffer.VertexBuffer)
+ self.assertEqual(buf.type(), QOpenGLBuffer.Type.VertexBuffer)
buf.bind()
buf.allocate(128)
diff --git a/sources/pyside6/tests/QtOpenGL/qopenglwindow_test.py b/sources/pyside6/tests/QtOpenGL/qopenglwindow_test.py
index 85e80a077..5455557bb 100644
--- a/sources/pyside6/tests/QtOpenGL/qopenglwindow_test.py
+++ b/sources/pyside6/tests/QtOpenGL/qopenglwindow_test.py
@@ -44,13 +44,13 @@ class OpenGLWindow(QOpenGLWindow):
def initializeGL(self):
profile = QOpenGLVersionProfile()
profile.setVersion(1, 3)
- profile.setProfile(QSurfaceFormat.CompatibilityProfile)
+ profile.setProfile(QSurfaceFormat.OpenGLContextProfile.CompatibilityProfile)
self.m_functions = QOpenGLVersionFunctionsFactory.get(profile)
self.m_functions.initializeOpenGLFunctions()
print("GL_MAX_LIGHTS=", self.m_functions.glGetIntegerv(GL.GL_MAX_LIGHTS))
- image = QImage(QSize(200, 200), QImage.Format_RGBA8888)
- image.fill(QColor(Qt.red))
+ image = QImage(QSize(200, 200), QImage.Format.Format_RGBA8888)
+ image.fill(QColor(Qt.GlobalColor.red))
self.m_texture = QOpenGLTexture(image)
def paintGL(self):
diff --git a/sources/pyside6/tests/QtQml/bug_814.py b/sources/pyside6/tests/QtQml/bug_814.py
index 955b24c7e..e75990208 100644
--- a/sources/pyside6/tests/QtQml/bug_814.py
+++ b/sources/pyside6/tests/QtQml/bug_814.py
@@ -37,13 +37,13 @@ class ListModel(QAbstractListModel):
super().__init__()
def roleNames(self):
- return {Qt.DisplayRole: b'pysideModelData'}
+ return {Qt.ItemDataRole.DisplayRole: b'pysideModelData'}
def rowCount(self, parent=QModelIndex()):
return 3
def data(self, index, role):
- if index.isValid() and role == Qt.DisplayRole:
+ if index.isValid() and role == Qt.ItemDataRole.DisplayRole:
return 'blubb'
return None
diff --git a/sources/pyside6/tests/QtQml/bug_825.py b/sources/pyside6/tests/QtQml/bug_825.py
index 07c91fd49..47d734931 100644
--- a/sources/pyside6/tests/QtQml/bug_825.py
+++ b/sources/pyside6/tests/QtQml/bug_825.py
@@ -52,7 +52,7 @@ class Bug825 (C):
def paint(self, painter):
global paintCalled
- pen = QPen(Qt.black, 2)
+ pen = QPen(Qt.GlobalColor.black, 2)
painter.setPen(pen)
painter.drawPie(self.boundingRect(), 0, 128)
paintCalled = True
diff --git a/sources/pyside6/tests/QtQml/bug_825_old.py b/sources/pyside6/tests/QtQml/bug_825_old.py
index e1a35d3d9..88d288ee6 100644
--- a/sources/pyside6/tests/QtQml/bug_825_old.py
+++ b/sources/pyside6/tests/QtQml/bug_825_old.py
@@ -52,7 +52,7 @@ class Bug825 (C):
def paint(self, painter):
global paintCalled
- pen = QPen(Qt.black, 2)
+ pen = QPen(Qt.GlobalColor.black, 2)
painter.setPen(pen)
painter.drawPie(self.boundingRect(), 0, 128)
paintCalled = True
diff --git a/sources/pyside6/tests/QtQml/bug_847.py b/sources/pyside6/tests/QtQml/bug_847.py
index e7f5847e8..557cf967b 100644
--- a/sources/pyside6/tests/QtQml/bug_847.py
+++ b/sources/pyside6/tests/QtQml/bug_847.py
@@ -50,9 +50,9 @@ class TestQML(UsesQApplication):
file = Path(__file__).resolve().parent / 'bug_847.qml'
self.assertTrue(file.is_file())
view.setSource(QUrl.fromLocalFile(file))
- while view.status() == QQuickView.Loading:
+ while view.status() == QQuickView.Status.Loading:
self.app.processEvents()
- self.assertEqual(view.status(), QQuickView.Ready)
+ self.assertEqual(view.status(), QQuickView.Status.Ready)
self.assertTrue(view.rootObject(), quickview_errorstring(view))
view.rootObject().setProperty('pythonObject', view)
diff --git a/sources/pyside6/tests/QtQml/qqmlincubator_incubateWhile.py b/sources/pyside6/tests/QtQml/qqmlincubator_incubateWhile.py
index e5b6418a2..f5f7d70ef 100644
--- a/sources/pyside6/tests/QtQml/qqmlincubator_incubateWhile.py
+++ b/sources/pyside6/tests/QtQml/qqmlincubator_incubateWhile.py
@@ -10,15 +10,15 @@ import unittest
from pathlib import Path
sys.path.append(os.fspath(Path(__file__).resolve().parents[1]))
-from init_paths import init_test_paths
+from init_paths import init_test_paths # noqa: E402
init_test_paths(False)
-from helper.helper import quickview_errorstring
+from helper.helper import quickview_errorstring # noqa: E402
-from PySide6.QtCore import QObject, QUrl, Slot, QTimer
-from PySide6.QtGui import QGuiApplication
-from PySide6.QtQml import QQmlIncubationController, VolatileBool
-from PySide6.QtQuick import QQuickView
+from PySide6.QtCore import QObject, QUrl, Slot, QTimer # noqa: E402
+from PySide6.QtGui import QGuiApplication # noqa: E402
+from PySide6.QtQml import QQmlIncubationController, VolatileBool # noqa: E402
+from PySide6.QtQuick import QQuickView # noqa: E402
class CustomIncubationController(QObject, QQmlIncubationController):
@@ -52,7 +52,7 @@ class TestBug(unittest.TestCase):
view = QQuickView()
controller = CustomIncubationController(self)
view.engine().setIncubationController(controller)
- view.setResizeMode(QQuickView.SizeRootObjectToView)
+ view.setResizeMode(QQuickView.ResizeMode.SizeRootObjectToView)
file = Path(__file__).resolve().parent / 'qqmlincubator_incubateWhile.qml'
self.assertTrue(file.is_file())
view.setSource(QUrl.fromLocalFile(file))
@@ -62,7 +62,7 @@ class TestBug(unittest.TestCase):
root = view.rootObject()
# The QML code will issue an interrupt signal after half of its items are loaded.
root.shouldInterrupt.connect(controller.interrupter)
- res = app.exec()
+ res = app.exec() # noqa: F841
itemsToCreate = root.property("itemsToCreate")
loadedItems = root.property("loadedItems")
diff --git a/sources/pyside6/tests/QtQml/qqmlnetwork_test.py b/sources/pyside6/tests/QtQml/qqmlnetwork_test.py
index ea8ce6238..6700f2c38 100644
--- a/sources/pyside6/tests/QtQml/qqmlnetwork_test.py
+++ b/sources/pyside6/tests/QtQml/qqmlnetwork_test.py
@@ -65,7 +65,7 @@ class TestQQmlNetworkFactory(TimedQGuiApplication):
self.assertTrue(view.rootObject(), quickview_errorstring(view))
view.show()
- self.assertEqual(view.status(), QQuickView.Ready)
+ self.assertEqual(view.status(), QQuickView.Status.Ready)
timer = QTimer()
timer.timeout.connect(check_done)
diff --git a/sources/pyside6/tests/QtQml/qquickview_test.py b/sources/pyside6/tests/QtQml/qquickview_test.py
index 9e4b45c5c..eaca08e46 100644
--- a/sources/pyside6/tests/QtQml/qquickview_test.py
+++ b/sources/pyside6/tests/QtQml/qquickview_test.py
@@ -54,7 +54,7 @@ class TestQQuickView(TimedQGuiApplication):
self.assertTrue(view.rootObject(), quickview_errorstring(view))
view.show()
- self.assertEqual(view.status(), QQuickView.Ready)
+ self.assertEqual(view.status(), QQuickView.Status.Ready)
rootObject = view.rootObject()
self.assertTrue(rootObject)
context = QQmlEngine.contextForObject(rootObject)
@@ -81,7 +81,7 @@ class TestQQuickView(TimedQGuiApplication):
self.assertTrue(view.rootObject(), quickview_errorstring(view))
view.show()
- self.assertEqual(view.status(), QQuickView.Ready)
+ self.assertEqual(view.status(), QQuickView.Status.Ready)
if __name__ == '__main__':
diff --git a/sources/pyside6/tests/QtQml/registertype.py b/sources/pyside6/tests/QtQml/registertype.py
index 78a10d24b..b90c05011 100644
--- a/sources/pyside6/tests/QtQml/registertype.py
+++ b/sources/pyside6/tests/QtQml/registertype.py
@@ -58,7 +58,7 @@ class PieSlice (QQuickPaintedItem):
global paintCalled
pen = QPen(self._color, 2)
painter.setPen(pen)
- painter.setRenderHints(QPainter.Antialiasing, True)
+ painter.setRenderHints(QPainter.RenderHint.Antialiasing, True)
painter.drawPie(self.boundingRect(), self._fromAngle * 16, self._angleSpan * 16)
paintCalled = True
diff --git a/sources/pyside6/tests/QtQml/registeruncreatabletype.py b/sources/pyside6/tests/QtQml/registeruncreatabletype.py
index e9ad9226b..944c011a4 100644
--- a/sources/pyside6/tests/QtQml/registeruncreatabletype.py
+++ b/sources/pyside6/tests/QtQml/registeruncreatabletype.py
@@ -48,7 +48,7 @@ class TestQmlSupport(unittest.TestCase):
component = QQmlComponent(engine, QUrl.fromLocalFile(file))
# Check that the uncreatable item produces the correct error
- self.assertEqual(component.status(), QQmlComponent.Error)
+ self.assertEqual(component.status(), QQmlComponent.Status.Error)
errorFound = False
for e in component.errors():
if noCreationReason in e.toString():
diff --git a/sources/pyside6/tests/QtSerialPort/serial.py b/sources/pyside6/tests/QtSerialPort/serial.py
index 6107b2a92..ea55eb113 100644
--- a/sources/pyside6/tests/QtSerialPort/serial.py
+++ b/sources/pyside6/tests/QtSerialPort/serial.py
@@ -11,36 +11,36 @@ import unittest
from pathlib import Path
sys.path.append(os.fspath(Path(__file__).resolve().parents[1]))
-from init_paths import init_test_paths
+from init_paths import init_test_paths # noqa: E402
init_test_paths(False)
-from PySide6.QtSerialPort import QSerialPort, QSerialPortInfo
-from PySide6.QtCore import QIODevice
+from PySide6.QtSerialPort import QSerialPort, QSerialPortInfo # noqa: E402
+from PySide6.QtCore import QIODevice # noqa: E402
class QSerialPortTest(unittest.TestCase):
def testDefaultConstructedPort(self):
serialPort = QSerialPort()
- self.assertEqual(serialPort.error(), QSerialPort.NoError)
+ self.assertEqual(serialPort.error(), QSerialPort.SerialPortError.NoError)
self.assertTrue(not serialPort.errorString() == "")
# properties
- defaultBaudRate = QSerialPort.Baud9600
+ defaultBaudRate = QSerialPort.BaudRate.Baud9600
self.assertEqual(serialPort.baudRate(), defaultBaudRate)
- self.assertEqual(serialPort.baudRate(QSerialPort.Input), defaultBaudRate)
- self.assertEqual(serialPort.baudRate(QSerialPort.Output), defaultBaudRate)
- self.assertEqual(serialPort.dataBits(), QSerialPort.Data8)
- self.assertEqual(serialPort.parity(), QSerialPort.NoParity)
- self.assertEqual(serialPort.stopBits(), QSerialPort.OneStop)
- self.assertEqual(serialPort.flowControl(), QSerialPort.NoFlowControl)
+ self.assertEqual(serialPort.baudRate(QSerialPort.Direction.Input), defaultBaudRate)
+ self.assertEqual(serialPort.baudRate(QSerialPort.Direction.Output), defaultBaudRate)
+ self.assertEqual(serialPort.dataBits(), QSerialPort.DataBits.Data8)
+ self.assertEqual(serialPort.parity(), QSerialPort.Parity.NoParity)
+ self.assertEqual(serialPort.stopBits(), QSerialPort.StopBits.OneStop)
+ self.assertEqual(serialPort.flowControl(), QSerialPort.FlowControl.NoFlowControl)
- self.assertEqual(serialPort.pinoutSignals(), QSerialPort.NoSignal)
+ self.assertEqual(serialPort.pinoutSignals(), QSerialPort.PinoutSignal.NoSignal)
self.assertEqual(serialPort.isRequestToSend(), False)
self.assertEqual(serialPort.isDataTerminalReady(), False)
# QIODevice
- self.assertEqual(serialPort.openMode(), QIODevice.NotOpen)
+ self.assertEqual(serialPort.openMode(), QIODevice.OpenModeFlag.NotOpen)
self.assertTrue(not serialPort.isOpen())
self.assertTrue(not serialPort.isReadable())
self.assertTrue(not serialPort.isWritable())
diff --git a/sources/pyside6/tests/QtSvg/qsvgrenderer_test.py b/sources/pyside6/tests/QtSvg/qsvgrenderer_test.py
index 2c5151724..22d932ed6 100644
--- a/sources/pyside6/tests/QtSvg/qsvgrenderer_test.py
+++ b/sources/pyside6/tests/QtSvg/qsvgrenderer_test.py
@@ -27,7 +27,7 @@ class QSvgRendererTest(unittest.TestCase):
self.assertTrue(fromFile.isValid())
tigerFile = QFile(tigerPath)
- tigerFile.open(QFile.ReadOnly)
+ tigerFile.open(QFile.OpenModeFlag.ReadOnly)
tigerData = tigerFile.readAll()
fromContents = QSvgRenderer(tigerData)
self.assertTrue(fromContents.isValid())
diff --git a/sources/pyside6/tests/QtSvgWidgets/qsvgwidget_test.py b/sources/pyside6/tests/QtSvgWidgets/qsvgwidget_test.py
index a1a718733..28e693dc2 100644
--- a/sources/pyside6/tests/QtSvgWidgets/qsvgwidget_test.py
+++ b/sources/pyside6/tests/QtSvgWidgets/qsvgwidget_test.py
@@ -30,7 +30,7 @@ class QSvgWidgetTest(unittest.TestCase):
self.assertTrue(fromFile.renderer().isValid())
tigerFile = QFile(tigerPath)
- tigerFile.open(QFile.ReadOnly)
+ tigerFile.open(QFile.OpenModeFlag.ReadOnly)
tigerData = tigerFile.readAll()
fromContents = QSvgWidget()
fromContents.load(tigerData)
diff --git a/sources/pyside6/tests/QtTest/click_test.py b/sources/pyside6/tests/QtTest/click_test.py
index dbfa3a26d..0d86c1704 100644
--- a/sources/pyside6/tests/QtTest/click_test.py
+++ b/sources/pyside6/tests/QtTest/click_test.py
@@ -28,10 +28,10 @@ class MouseClickTest(UsesQApplication):
button.setCheckable(True)
button.setChecked(False)
- QTest.mouseClick(button, Qt.LeftButton)
+ QTest.mouseClick(button, Qt.MouseButton.LeftButton)
self.assertTrue(button.isChecked())
- QTest.mouseClick(button, Qt.LeftButton)
+ QTest.mouseClick(button, Qt.MouseButton.LeftButton)
self.assertFalse(button.isChecked())
diff --git a/sources/pyside6/tests/QtTest/eventfilter_test.py b/sources/pyside6/tests/QtTest/eventfilter_test.py
index 07b8c4eb0..80a8307e6 100644
--- a/sources/pyside6/tests/QtTest/eventfilter_test.py
+++ b/sources/pyside6/tests/QtTest/eventfilter_test.py
@@ -33,8 +33,8 @@ class KeyEventFilter(QObject):
self.processed = False
def eventFilter(self, obj, event):
- if self.widget == obj and event.type() == self.eventType and \
- isinstance(event, QKeyEvent) and event.key() == self.key:
+ if (self.widget == obj and event.type() == self.eventType
+ and isinstance(event, QKeyEvent) and event.key() == self.key):
self.processed = True
return True
@@ -45,8 +45,8 @@ class EventFilterTest(UsesQApplication):
def testKeyEvent(self):
widget = QLineEdit()
- key = Qt.Key_A
- eventFilter = KeyEventFilter(widget, QEvent.KeyPress, key)
+ key = Qt.Key.Key_A
+ eventFilter = KeyEventFilter(widget, QEvent.Type.KeyPress, key)
widget.installEventFilter(eventFilter)
QTest.keyClick(widget, key)
diff --git a/sources/pyside6/tests/QtTest/qvalidator_test.py b/sources/pyside6/tests/QtTest/qvalidator_test.py
index 081b77b55..b362a27a2 100644
--- a/sources/pyside6/tests/QtTest/qvalidator_test.py
+++ b/sources/pyside6/tests/QtTest/qvalidator_test.py
@@ -23,7 +23,7 @@ class MyValidator1(QValidator):
return "fixed"
def validate(self, input, pos):
- return (QValidator.Acceptable, "fixed", 1)
+ return (QValidator.State.Acceptable, "fixed", 1)
class MyValidator2(QValidator):
@@ -31,7 +31,7 @@ class MyValidator2(QValidator):
return "fixed"
def validate(self, input, pos):
- return (QValidator.Acceptable, "fixed")
+ return (QValidator.State.Acceptable, "fixed")
class MyValidator3(QValidator):
@@ -39,7 +39,7 @@ class MyValidator3(QValidator):
return "fixed"
def validate(self, input, pos):
- return (QValidator.Acceptable,)
+ return (QValidator.State.Acceptable,)
class MyValidator4(QValidator):
@@ -47,15 +47,15 @@ class MyValidator4(QValidator):
return "fixed"
def validate(self, input, pos):
- return QValidator.Acceptable
+ return QValidator.State.Acceptable
class MyValidator5(QValidator):
def validate(self, input, pos):
if input.islower():
- return (QValidator.Intermediate, input, pos)
+ return (QValidator.State.Intermediate, input, pos)
else:
- return (QValidator.Acceptable, input, pos)
+ return (QValidator.State.Acceptable, input, pos)
def fixup(self, input):
return "22"
@@ -115,7 +115,7 @@ class QValidatorTest(UsesQApplication):
line.show()
line.setValidator(MyValidator5())
line.setText("foo")
- QTest.keyClick(line, Qt.Key_Return)
+ QTest.keyClick(line, Qt.Key.Key_Return)
self.assertEqual(line.text(), "22")
diff --git a/sources/pyside6/tests/QtWebEngineCore/web_engine_custom_scheme.py b/sources/pyside6/tests/QtWebEngineCore/web_engine_custom_scheme.py
index 4d1cb6b0b..47593e242 100644
--- a/sources/pyside6/tests/QtWebEngineCore/web_engine_custom_scheme.py
+++ b/sources/pyside6/tests/QtWebEngineCore/web_engine_custom_scheme.py
@@ -8,15 +8,14 @@ import unittest
from pathlib import Path
sys.path.append(os.fspath(Path(__file__).resolve().parents[1]))
-from init_paths import init_test_paths
+from init_paths import init_test_paths # noqa: E402
init_test_paths(False)
-from PySide6.QtCore import QBuffer, Qt, QTimer
-from PySide6.QtWidgets import QApplication, QWidget, QVBoxLayout
-from PySide6.QtWebEngineWidgets import QWebEngineView
-from PySide6.QtWebEngineCore import (QWebEngineProfile,
- QWebEngineUrlScheme,
- QWebEngineUrlSchemeHandler)
+from PySide6.QtCore import QBuffer, Qt, QTimer # noqa: E402
+from PySide6.QtWidgets import QApplication, QWidget, QVBoxLayout # noqa: E402
+from PySide6.QtWebEngineWidgets import QWebEngineView # noqa: E402
+from PySide6.QtWebEngineCore import (QWebEngineProfile, QWebEngineUrlScheme, # noqa: E402
+ QWebEngineUrlSchemeHandler) # noqa: E402
class TestSchemeHandler(QWebEngineUrlSchemeHandler):
@@ -34,7 +33,7 @@ class TestSchemeHandler(QWebEngineUrlSchemeHandler):
class MainTest(unittest.TestCase):
def test_SchemeHandlerRedirect(self):
self._loaded = False
- QApplication.setAttribute(Qt.AA_ShareOpenGLContexts)
+ QApplication.setAttribute(Qt.ApplicationAttribute.AA_ShareOpenGLContexts)
app = QApplication([])
scheme_name = bytes("testpy", "UTF-8")
diff --git a/sources/pyside6/tests/QtWidgets/add_action_test.py b/sources/pyside6/tests/QtWidgets/add_action_test.py
index 69ec3e9f5..a6005bde0 100644
--- a/sources/pyside6/tests/QtWidgets/add_action_test.py
+++ b/sources/pyside6/tests/QtWidgets/add_action_test.py
@@ -40,8 +40,8 @@ class AddActionTest(UsesQApplication):
'''QMenuBar.addAction(id, callback)'''
menubar = QMenuBar()
action = menubar.addAction("Accounts", self._callback)
- action.activate(QAction.Trigger)
- action.setShortcut(Qt.Key_A)
+ action.activate(QAction.ActionEvent.Trigger)
+ action.setShortcut(Qt.Key.Key_A)
self.assertTrue(self.called)
def testWithCppSlot(self):
@@ -51,8 +51,8 @@ class AddActionTest(UsesQApplication):
widget.setCheckable(True)
widget.setChecked(False)
action = menubar.addAction("Accounts", widget, SLOT("toggle()"))
- action.setShortcut(Qt.Key_A)
- action.activate(QAction.Trigger)
+ action.setShortcut(Qt.Key.Key_A)
+ action.activate(QAction.ActionEvent.Trigger)
self.assertTrue(widget.isChecked())
diff --git a/sources/pyside6/tests/QtWidgets/api2_test.py b/sources/pyside6/tests/QtWidgets/api2_test.py
index 1df67d002..fd3bfd862 100644
--- a/sources/pyside6/tests/QtWidgets/api2_test.py
+++ b/sources/pyside6/tests/QtWidgets/api2_test.py
@@ -43,9 +43,9 @@ class DoubleQObjectInheritanceTest(UsesQApplication):
# QIntValidator methods
state, string, number = obj.validate('Test', 0)
- self.assertEqual(state, QValidator.Invalid)
+ self.assertEqual(state, QValidator.State.Invalid)
state, string, number = obj.validate('33', 0)
- self.assertEqual(state, QValidator.Acceptable)
+ self.assertEqual(state, QValidator.State.Acceptable)
def testQSpinBox(self):
obj = WidgetValidatorQSpinBox()
diff --git a/sources/pyside6/tests/QtWidgets/bug_1006.py b/sources/pyside6/tests/QtWidgets/bug_1006.py
index 87d73c4ec..9baf85def 100644
--- a/sources/pyside6/tests/QtWidgets/bug_1006.py
+++ b/sources/pyside6/tests/QtWidgets/bug_1006.py
@@ -32,7 +32,7 @@ class LabelWindow(QDialog):
def replace(self, unit):
old_item = self.test_layout.itemAtPosition(0, 0)
old_label = old_item.widget()
- ref = weakref.ref(old_item, self._destroyed)
+ ref = weakref.ref(old_item, self._destroyed) # noqa: F841
self.test_layout.removeWidget(old_label)
unit.assertRaises(RuntimeError, old_item.widget)
@@ -42,7 +42,7 @@ class LabelWindow(QDialog):
label = QLabel("Label New")
old_label.deleteLater()
- label.setAlignment(Qt.AlignCenter)
+ label.setAlignment(Qt.AlignmentFlag.AlignCenter)
self.test_layout.addWidget(label, 0, 0)
def _destroyed(self, obj):
diff --git a/sources/pyside6/tests/QtWidgets/bug_389.py b/sources/pyside6/tests/QtWidgets/bug_389.py
index 39e0aa5d6..60305a8b1 100644
--- a/sources/pyside6/tests/QtWidgets/bug_389.py
+++ b/sources/pyside6/tests/QtWidgets/bug_389.py
@@ -21,7 +21,7 @@ from PySide6.QtWidgets import QStyle, QWidget
class BugTest(UsesQApplication):
def testCase(self):
s = QWidget().style()
- i = s.standardIcon(QStyle.SP_TitleBarMinButton)
+ i = s.standardIcon(QStyle.StandardPixmap.SP_TitleBarMinButton)
self.assertEqual(type(i), QIcon)
diff --git a/sources/pyside6/tests/QtWidgets/bug_688.py b/sources/pyside6/tests/QtWidgets/bug_688.py
index 3eadf35ad..db34f6691 100644
--- a/sources/pyside6/tests/QtWidgets/bug_688.py
+++ b/sources/pyside6/tests/QtWidgets/bug_688.py
@@ -22,13 +22,13 @@ class BugTest(UsesQApplication):
def testCase(self):
editor = QTextEdit()
cursor = QTextCursor(editor.textCursor())
- cursor.movePosition(QTextCursor.Start)
+ cursor.movePosition(QTextCursor.MoveOperation.Start)
mainFrame = cursor.currentFrame()
plainCharFormat = QTextCharFormat()
boldCharFormat = QTextCharFormat()
- boldCharFormat.setFontWeight(QFont.Bold)
+ boldCharFormat.setFontWeight(QFont.Weight.Bold)
cursor.insertText("""
Text documents are represented by the
QTextDocument class, rather than by QString objects.
diff --git a/sources/pyside6/tests/QtWidgets/bug_736.py b/sources/pyside6/tests/QtWidgets/bug_736.py
index 2e471b04a..133a8001f 100644
--- a/sources/pyside6/tests/QtWidgets/bug_736.py
+++ b/sources/pyside6/tests/QtWidgets/bug_736.py
@@ -17,9 +17,9 @@ from PySide6.QtWidgets import QApplication, QSlider
class TestBug736 (unittest.TestCase):
def testIt(self):
- app = QApplication([])
- slider = QSlider(Qt.Horizontal)
- slider2 = QSlider(Qt.Horizontal)
+ app = QApplication([]) # noqa: F841
+ slider = QSlider(Qt.Orientation.Horizontal)
+ slider2 = QSlider(Qt.Orientation.Horizontal)
slider2.setMaximum(10)
slider.valueChanged[int].connect(slider2.setMaximum)
diff --git a/sources/pyside6/tests/QtWidgets/bug_879.py b/sources/pyside6/tests/QtWidgets/bug_879.py
index a2b49d954..acd0196c9 100644
--- a/sources/pyside6/tests/QtWidgets/bug_879.py
+++ b/sources/pyside6/tests/QtWidgets/bug_879.py
@@ -36,7 +36,8 @@ class TestBug879 (unittest.TestCase):
self.assertEqual(self.box.text(), '0')
def sendKbdEvent(self):
- ev = QKeyEvent(QEvent.KeyPress, Qt.Key_A, Qt.NoModifier, 'a')
+ ev = QKeyEvent(QEvent.Type.KeyPress, Qt.Key.Key_A,
+ Qt.KeyboardModifier.NoModifier, 'a')
QCoreApplication.sendEvent(self.box, ev)
diff --git a/sources/pyside6/tests/QtWidgets/bug_919.py b/sources/pyside6/tests/QtWidgets/bug_919.py
index 3094d7483..6f2fc128d 100644
--- a/sources/pyside6/tests/QtWidgets/bug_919.py
+++ b/sources/pyside6/tests/QtWidgets/bug_919.py
@@ -29,7 +29,7 @@ class MyWidget(QPushButton):
p = QPainter(self)
style = QApplication.style()
option = QStyleOptionButton()
- style.drawControl(QStyle.CE_PushButton, option, p)
+ style.drawControl(QStyle.ControlElement.CE_PushButton, option, p)
self._painted = True
QTimer.singleShot(0, self._emitPainted)
diff --git a/sources/pyside6/tests/QtWidgets/bug_921.py b/sources/pyside6/tests/QtWidgets/bug_921.py
index ef84219c4..bdd18daf5 100644
--- a/sources/pyside6/tests/QtWidgets/bug_921.py
+++ b/sources/pyside6/tests/QtWidgets/bug_921.py
@@ -28,7 +28,7 @@ class Window:
def __init__(self, s):
self._window = QMainWindow()
- self._window.setAttribute(Qt.WA_DeleteOnClose, True)
+ self._window.setAttribute(Qt.WidgetAttribute.WA_DeleteOnClose, True)
self._window.setWindowTitle("Demo!")
self._s = s
diff --git a/sources/pyside6/tests/QtWidgets/bug_941.py b/sources/pyside6/tests/QtWidgets/bug_941.py
index 6e09b8ed7..f5972d335 100644
--- a/sources/pyside6/tests/QtWidgets/bug_941.py
+++ b/sources/pyside6/tests/QtWidgets/bug_941.py
@@ -22,10 +22,11 @@ def foo(a, b):
class TestBug941 (unittest.TestCase):
def testIt(self):
- app = QApplication([])
- view = QHeaderView(Qt.Horizontal)
+ app = QApplication([]) # noqa: F841
+ view = QHeaderView(Qt.Orientation.Horizontal)
self.assertTrue(view.sortIndicatorChanged.connect(foo))
- view.sortIndicatorChanged.emit(0, Qt.Vertical) # this can't raise an exception!
+ # this can't raise an exception!
+ view.sortIndicatorChanged.emit(0, Qt.Orientation.Vertical)
if __name__ == '__main__':
diff --git a/sources/pyside6/tests/QtWidgets/bug_964.py b/sources/pyside6/tests/QtWidgets/bug_964.py
index 146873259..f018d4af9 100644
--- a/sources/pyside6/tests/QtWidgets/bug_964.py
+++ b/sources/pyside6/tests/QtWidgets/bug_964.py
@@ -18,12 +18,13 @@ from PySide6.QtWidgets import QAbstractItemView, QApplication, QListView
class TestBug964 (unittest.TestCase):
def testIt(self):
- app = QApplication([])
+ app = QApplication([]) # noqa: F841
model = QStringListModel(["1", "2"])
view = QListView()
view.setModel(model)
view.setCurrentIndex(model.index(0, 0))
- newCursor = view.moveCursor(QAbstractItemView.MoveDown, Qt.NoModifier)
+ newCursor = view.moveCursor(QAbstractItemView.CursorAction.MoveDown,
+ Qt.KeyboardModifier.NoModifier)
self.assertEqual(newCursor.row(), 1)
self.assertEqual(newCursor.column(), 0)
diff --git a/sources/pyside6/tests/QtWidgets/bug_972.py b/sources/pyside6/tests/QtWidgets/bug_972.py
index 1450cc16b..77c16f1ca 100644
--- a/sources/pyside6/tests/QtWidgets/bug_972.py
+++ b/sources/pyside6/tests/QtWidgets/bug_972.py
@@ -12,7 +12,8 @@ from init_paths import init_test_paths
init_test_paths(False)
from PySide6.QtCore import QSizeF
-from PySide6.QtWidgets import QGraphicsProxyWidget, QSizePolicy, QPushButton, QGraphicsScene, QGraphicsView
+from PySide6.QtWidgets import (QGraphicsProxyWidget, QSizePolicy, QPushButton,
+ QGraphicsScene, QGraphicsView)
from helper.timedqapplication import TimedQApplication
@@ -24,7 +25,7 @@ def createItem(minimum, preferred, maximum, name):
w.setMinimumSize(minimum)
w.setPreferredSize(preferred)
w.setMaximumSize(maximum)
- w.setSizePolicy(QSizePolicy.Preferred, QSizePolicy.Preferred)
+ w.setSizePolicy(QSizePolicy.Policy.Preferred, QSizePolicy.Policy.Preferred)
return w
@@ -39,10 +40,10 @@ class TestBug972 (TimedQApplication):
prefSize = QSizeF(210, 100)
maxSize = QSizeF(300, 100)
- a = createItem(minSize, prefSize, maxSize, "A")
- b = createItem(minSize, prefSize, maxSize, "B")
- c = createItem(minSize, prefSize, maxSize, "C")
- d = createItem(minSize, prefSize, maxSize, "D")
+ a = createItem(minSize, prefSize, maxSize, "A") # noqa: F841
+ b = createItem(minSize, prefSize, maxSize, "B") # noqa: F841
+ c = createItem(minSize, prefSize, maxSize, "C") # noqa: F841
+ d = createItem(minSize, prefSize, maxSize, "D") # noqa: F841
view = QGraphicsView(scene)
view.show()
diff --git a/sources/pyside6/tests/QtWidgets/customproxywidget_test.py b/sources/pyside6/tests/QtWidgets/customproxywidget_test.py
index 7bff22778..9e1ec6dac 100644
--- a/sources/pyside6/tests/QtWidgets/customproxywidget_test.py
+++ b/sources/pyside6/tests/QtWidgets/customproxywidget_test.py
@@ -27,16 +27,17 @@ class CustomProxyWidgetTest(UsesQApplication):
def testCustomProxyWidget(self):
scene = QGraphicsScene()
- proxy = CustomProxy(None, Qt.Window)
+ proxy = CustomProxy(None, Qt.WindowType.Window)
widget = QLabel('Widget')
proxy.setWidget(widget)
- proxy.setCacheMode(QGraphicsItem.DeviceCoordinateCache)
+ proxy.setCacheMode(QGraphicsItem.CacheMode.DeviceCoordinateCache)
scene.addItem(proxy)
scene.setSceneRect(scene.itemsBoundingRect())
view = QGraphicsView(scene)
- view.setRenderHints(QPainter.Antialiasing | QPainter.SmoothPixmapTransform)
- view.setViewportUpdateMode(QGraphicsView.BoundingRectViewportUpdate)
+ view.setRenderHints(QPainter.RenderHint.Antialiasing
+ | QPainter.RenderHint.SmoothPixmapTransform)
+ view.setViewportUpdateMode(QGraphicsView.ViewportUpdateMode.BoundingRectViewportUpdate)
view.show()
QTimer.singleShot(100, self.app.quit)
diff --git a/sources/pyside6/tests/QtWidgets/qaccessible_test.py b/sources/pyside6/tests/QtWidgets/qaccessible_test.py
index 66c68fa27..5fdb64d01 100644
--- a/sources/pyside6/tests/QtWidgets/qaccessible_test.py
+++ b/sources/pyside6/tests/QtWidgets/qaccessible_test.py
@@ -40,7 +40,7 @@ class LineEditAccessible(QAccessibleInterface):
return None
def backgroundColor(self):
- return QColor(Qt.white)
+ return QColor(Qt.GlobalColor.white)
def child(self, index):
return None
@@ -55,7 +55,7 @@ class LineEditAccessible(QAccessibleInterface):
return None
def foregroundColor(self):
- return QColor(Qt.black)
+ return QColor(Qt.GlobalColor.black)
def indexOfChild(self, child):
return -1
@@ -125,7 +125,7 @@ class QAccessibleTest(UsesQApplication):
def setUp(self):
super().setUp()
QAccessible.installFactory(accessible_factory)
- window = Window()
+ window = Window() # noqa: F841
def testLineEdits(self):
window = Window()
diff --git a/sources/pyside6/tests/QtWidgets/qdynamic_signal.py b/sources/pyside6/tests/QtWidgets/qdynamic_signal.py
index 6d903f85c..4ebaddf17 100644
--- a/sources/pyside6/tests/QtWidgets/qdynamic_signal.py
+++ b/sources/pyside6/tests/QtWidgets/qdynamic_signal.py
@@ -9,13 +9,13 @@ import unittest
from pathlib import Path
sys.path.append(os.fspath(Path(__file__).resolve().parents[1]))
-from init_paths import init_test_paths
+from init_paths import init_test_paths # noqa: E402
init_test_paths(False)
-from PySide6.QtCore import QObject
-from PySide6.QtWidgets import QInputDialog
+from PySide6.QtCore import QObject # noqa: E402
+from PySide6.QtWidgets import QInputDialog # noqa: E402
-from helper.usesqapplication import UsesQApplication
+from helper.usesqapplication import UsesQApplication # noqa: E402
class DynamicSignalTest(UsesQApplication):
@@ -25,7 +25,7 @@ class DynamicSignalTest(UsesQApplication):
def testQDialog(self):
dlg = QInputDialog()
- dlg.setInputMode(QInputDialog.TextInput)
+ dlg.setInputMode(QInputDialog.InputMode.TextInput)
lst = dlg.children()
self.assertTrue(len(lst))
obj = lst[0]
diff --git a/sources/pyside6/tests/QtWidgets/qformlayout_test.py b/sources/pyside6/tests/QtWidgets/qformlayout_test.py
index bcdaed8f7..3d0faf64e 100644
--- a/sources/pyside6/tests/QtWidgets/qformlayout_test.py
+++ b/sources/pyside6/tests/QtWidgets/qformlayout_test.py
@@ -32,7 +32,7 @@ class QFormLayoutTest(UsesQApplication):
self.assertTrue(isinstance(row, int))
self.assertTrue(isinstance(role, QFormLayout.ItemRole))
self.assertEqual(row, 0)
- self.assertEqual(role, QFormLayout.SpanningRole)
+ self.assertEqual(role, QFormLayout.ItemRole.SpanningRole)
def testGetWidgetPosition(self):
formlayout = QFormLayout()
@@ -48,7 +48,7 @@ class QFormLayoutTest(UsesQApplication):
self.assertTrue(isinstance(row, int))
self.assertTrue(isinstance(role, QFormLayout.ItemRole))
self.assertEqual(row, 0)
- self.assertEqual(role, QFormLayout.SpanningRole)
+ self.assertEqual(role, QFormLayout.ItemRole.SpanningRole)
def testGetLayoutPosition(self):
formlayout = QFormLayout()
@@ -64,7 +64,7 @@ class QFormLayoutTest(UsesQApplication):
self.assertTrue(isinstance(row, int))
self.assertTrue(isinstance(role, QFormLayout.ItemRole))
self.assertEqual(row, 0)
- self.assertEqual(role, QFormLayout.SpanningRole)
+ self.assertEqual(role, QFormLayout.ItemRole.SpanningRole)
def testTakeRow(self):
window = QMainWindow()
diff --git a/sources/pyside6/tests/QtWidgets/qgraphicsproxywidget_test.py b/sources/pyside6/tests/QtWidgets/qgraphicsproxywidget_test.py
index 92dfa871e..6a8123261 100644
--- a/sources/pyside6/tests/QtWidgets/qgraphicsproxywidget_test.py
+++ b/sources/pyside6/tests/QtWidgets/qgraphicsproxywidget_test.py
@@ -22,16 +22,17 @@ class QGraphicsProxyWidgetTest(UsesQApplication):
def testQGraphicsProxyWidget(self):
scene = QGraphicsScene()
- proxy = QGraphicsProxyWidget(None, Qt.Window)
+ proxy = QGraphicsProxyWidget(None, Qt.WindowType.Window)
widget = QLabel('Widget')
proxy.setWidget(widget)
- proxy.setCacheMode(QGraphicsItem.DeviceCoordinateCache)
+ proxy.setCacheMode(QGraphicsItem.CacheMode.DeviceCoordinateCache)
scene.addItem(proxy)
scene.setSceneRect(scene.itemsBoundingRect())
view = QGraphicsView(scene)
- view.setRenderHints(QPainter.Antialiasing | QPainter.SmoothPixmapTransform)
- view.setViewportUpdateMode(QGraphicsView.BoundingRectViewportUpdate)
+ view.setRenderHints(QPainter.RenderHint.Antialiasing
+ | QPainter.RenderHint.SmoothPixmapTransform)
+ view.setViewportUpdateMode(QGraphicsView.ViewportUpdateMode.BoundingRectViewportUpdate)
view.show()
QTimer.singleShot(100, self.app.quit)
diff --git a/sources/pyside6/tests/QtWidgets/qlayout_test.py b/sources/pyside6/tests/QtWidgets/qlayout_test.py
index 3df0e33dd..26449c346 100644
--- a/sources/pyside6/tests/QtWidgets/qlayout_test.py
+++ b/sources/pyside6/tests/QtWidgets/qlayout_test.py
@@ -69,32 +69,32 @@ class QLayoutTest(UsesQApplication):
@unittest.skipUnless(hasattr(sys, "getrefcount"), f"{sys.implementation.name} has no refcount")
def testOwnershipTransfer(self):
b = QPushButton("teste")
- l = MyLayout()
+ layout = MyLayout()
- l.addWidget(b)
+ layout.addWidget(b)
self.assertEqual(sys.getrefcount(b), 2)
w = QWidget()
# transfer ref
- w.setLayout(l)
+ w.setLayout(layout)
self.assertEqual(sys.getrefcount(b), 3)
@unittest.skipUnless(hasattr(sys, "getrefcount"), f"{sys.implementation.name} has no refcount")
def testReferenceTransfer(self):
b = QPushButton("teste")
- l = QHBoxLayout()
+ layout = QHBoxLayout()
# keep ref
- l.addWidget(b)
+ layout.addWidget(b)
self.assertEqual(sys.getrefcount(b), 3)
w = QWidget()
# transfer ref
- w.setLayout(l)
+ w.setLayout(layout)
self.assertEqual(sys.getrefcount(b), 3)
@@ -106,17 +106,17 @@ class QLayoutTest(UsesQApplication):
def testMissingFunctions(self):
w = QWidget()
b = QPushButton("test")
- l = MissingItemAtLayout()
+ layout = MissingItemAtLayout()
- l.addWidget(b)
+ layout.addWidget(b)
- self.assertRaises(RuntimeError, w.setLayout, l)
+ self.assertRaises(RuntimeError, w.setLayout, layout)
def testQFormLayout(self):
w = QWidget()
formLayout = QFormLayout()
spacer = QSpacerItem(100, 30)
- formLayout.setItem(0, QFormLayout.SpanningRole, spacer)
+ formLayout.setItem(0, QFormLayout.ItemRole.SpanningRole, spacer)
w.setLayout(formLayout)
w.show()
QTimer.singleShot(10, w.close)
diff --git a/sources/pyside6/tests/QtWidgets/qlistwidget_test.py b/sources/pyside6/tests/QtWidgets/qlistwidget_test.py
index c3dd31cc4..747fac7dd 100644
--- a/sources/pyside6/tests/QtWidgets/qlistwidget_test.py
+++ b/sources/pyside6/tests/QtWidgets/qlistwidget_test.py
@@ -24,7 +24,7 @@ class QListWidgetTest(UsesQApplication):
o.setObjectName("obj")
item = QListWidgetItem("item0")
- item.setData(Qt.UserRole, o)
+ item.setData(Qt.ItemDataRole.UserRole, o)
# item._data = o
self.assertTrue(sys.getrefcount(o), 3)
self.assertTrue(sys.getrefcount(item), 2)
@@ -59,7 +59,7 @@ class QListWidgetTest(UsesQApplication):
def testIt(self):
lst = QListWidget()
lst.show()
- slot = lambda: lst.removeItemWidget(lst.currentItem())
+ slot = lambda: lst.removeItemWidget(lst.currentItem()) # noqa: E731
lst.addItem(QListWidgetItem("foo"))
QTimer.singleShot(0, slot)
QTimer.singleShot(0, lst.close)
diff --git a/sources/pyside6/tests/QtWidgets/qobject_mi_test.py b/sources/pyside6/tests/QtWidgets/qobject_mi_test.py
index d98da04cf..ddf8e8040 100644
--- a/sources/pyside6/tests/QtWidgets/qobject_mi_test.py
+++ b/sources/pyside6/tests/QtWidgets/qobject_mi_test.py
@@ -42,9 +42,9 @@ class DoubleQObjectInheritanceTest(UsesQApplication):
# QIntValidator methods
state, string, number = obj.validate('aaaa', 0)
- self.assertEqual(state, QValidator.Invalid)
+ self.assertEqual(state, QValidator.State.Invalid)
state, string, number = obj.validate('33', 0)
- self.assertEqual(state, QValidator.Acceptable)
+ self.assertEqual(state, QValidator.State.Acceptable)
if __name__ == '__main__':
diff --git a/sources/pyside6/tests/QtWidgets/qpushbutton_test.py b/sources/pyside6/tests/QtWidgets/qpushbutton_test.py
index bf62e9129..e8f899296 100644
--- a/sources/pyside6/tests/QtWidgets/qpushbutton_test.py
+++ b/sources/pyside6/tests/QtWidgets/qpushbutton_test.py
@@ -43,7 +43,7 @@ class QPushButtonTest(UsesQApplication):
def testBoolinSignal(self):
b = QPushButton()
b.setCheckable(True)
- b.setShortcut(Qt.Key_A)
+ b.setShortcut(Qt.Key.Key_A)
self._clicked = False
b.toggled[bool].connect(self.buttonCb)
b.toggle()
diff --git a/sources/pyside6/tests/QtWidgets/qtreeview_test.py b/sources/pyside6/tests/QtWidgets/qtreeview_test.py
index 003475d54..1d259ba34 100644
--- a/sources/pyside6/tests/QtWidgets/qtreeview_test.py
+++ b/sources/pyside6/tests/QtWidgets/qtreeview_test.py
@@ -77,7 +77,7 @@ class QWidgetTest(UsesQApplication):
def testHeader(self):
tree = QTreeView()
- tree.setHeader(QHeaderView(Qt.Horizontal))
+ tree.setHeader(QHeaderView(Qt.Orientation.Horizontal))
self.assertIsNotNone(tree.header())
diff --git a/sources/pyside6/tests/QtWidgets/qvariant_test.py b/sources/pyside6/tests/QtWidgets/qvariant_test.py
index 74731e914..41a32ab76 100644
--- a/sources/pyside6/tests/QtWidgets/qvariant_test.py
+++ b/sources/pyside6/tests/QtWidgets/qvariant_test.py
@@ -81,9 +81,9 @@ class QVariantConversionTest(UsesQApplication):
"""
PYSIDE-1798: Test enum is obtained correctly when return through QVariant
"""
- self.obj.setProperty("test", Qt.SolidLine)
+ self.obj.setProperty("test", Qt.PenStyle.SolidLine)
self.assertTrue(isinstance(self.obj.property("test"), Qt.PenStyle))
- self.assertEqual(self.obj.property("test"), Qt.SolidLine)
+ self.assertEqual(self.obj.property("test"), Qt.PenStyle.SolidLine)
def testString(self):
self.obj.setProperty("test", "test")
diff --git a/sources/pyside6/tests/QtWidgets/standardpixmap_test.py b/sources/pyside6/tests/QtWidgets/standardpixmap_test.py
index 8fdd63e69..815e5bc49 100644
--- a/sources/pyside6/tests/QtWidgets/standardpixmap_test.py
+++ b/sources/pyside6/tests/QtWidgets/standardpixmap_test.py
@@ -19,7 +19,7 @@ from helper.usesqapplication import UsesQApplication
class StandardPixmapTest(UsesQApplication):
def testDefaultOptions(self): # Bug 253
- pixmap = self.app.style().standardPixmap(QStyle.SP_DirClosedIcon)
+ pixmap = self.app.style().standardPixmap(QStyle.StandardPixmap.SP_DirClosedIcon)
self.assertTrue(isinstance(pixmap, QPixmap))
diff --git a/sources/pyside6/tests/pysidetest/constructor_properties_test.py b/sources/pyside6/tests/pysidetest/constructor_properties_test.py
index 5d77a058a..331955f04 100644
--- a/sources/pyside6/tests/pysidetest/constructor_properties_test.py
+++ b/sources/pyside6/tests/pysidetest/constructor_properties_test.py
@@ -24,22 +24,22 @@ if not is_pypy:
class ConstructorPropertiesTest(unittest.TestCase):
def setUp(self):
- qApp or QApplication()
+ qApp or QApplication() # noqa: F821
if not is_pypy:
feature.reset()
def tearDown(self):
if not is_pypy:
feature.reset()
- qApp.shutdown()
+ qApp.shutdown() # noqa: F821
# PYSIDE-1019: First property extension was support by the constructor.
def testCallConstructor(self):
label = QLabel(
- frameStyle=QFrame.Panel | QFrame.Sunken, # QFrame attr, no property
- lineWidth=2, # QFrame property
- text="first line\nsecond line", # QLabel property
- alignment=Qt.AlignBottom | Qt.AlignRight # QLabel property
+ frameStyle=QFrame.Shape.Panel | QFrame.Shadow.Sunken, # QFrame attr, no property
+ lineWidth=2, # QFrame property
+ text="first line\nsecond line", # QLabel property
+ alignment=Qt.AlignmentFlag.AlignBottom | Qt.AlignmentFlag.AlignRight # QLabel property
)
self.assertEqual(label.lineWidth(), 2)
self.assertRaises(AttributeError, lambda: QLabel(
@@ -49,13 +49,13 @@ class ConstructorPropertiesTest(unittest.TestCase):
# PYSIDE-1705: The same with snake_case
@unittest.skipIf(is_pypy, "feature switching is not yet possible in PyPy")
def testCallConstructor_snake(self):
- from __feature__ import snake_case
+ from __feature__ import snake_case # noqa: F401
label = QLabel(
- frame_style=QFrame.Panel | QFrame.Sunken, # QFrame attr, no property
- line_width=2, # QFrame property
- text="first line\nsecond line", # QLabel property
- alignment=Qt.AlignBottom | Qt.AlignRight # QLabel property
+ frame_style=QFrame.Shape.Panel | QFrame.Shadow.Sunken, # QFrame attr, no property
+ line_width=2, # QFrame property
+ text="first line\nsecond line", # QLabel property
+ alignment=Qt.AlignmentFlag.AlignBottom | Qt.AlignmentFlag.AlignRight # QLabel property
)
self.assertEqual(label.line_width(), 2)
self.assertRaises(AttributeError, lambda: QLabel(
@@ -65,13 +65,13 @@ class ConstructorPropertiesTest(unittest.TestCase):
# PYSIDE-1705: The same with true_property
@unittest.skipIf(is_pypy, "feature switching is not yet possible in PyPy")
def testCallConstructor_prop(self):
- from __feature__ import true_property
+ from __feature__ import true_property # noqa: F401
label = QLabel(
- frameStyle=QFrame.Panel | QFrame.Sunken, # QFrame attr, no property
- lineWidth=2, # QFrame property
- text="first line\nsecond line", # QLabel property
- alignment=Qt.AlignBottom | Qt.AlignRight # QLabel property
+ frameStyle=QFrame.Shape.Panel | QFrame.Shadow.Sunken, # QFrame attr, no property
+ lineWidth=2, # QFrame property
+ text="first line\nsecond line", # QLabel property
+ alignment=Qt.AlignmentFlag.AlignBottom | Qt.AlignmentFlag.AlignRight # QLabel property
)
self.assertEqual(label.lineWidth, 2)
self.assertRaises(AttributeError, lambda: QLabel(
@@ -81,13 +81,13 @@ class ConstructorPropertiesTest(unittest.TestCase):
# PYSIDE-1705: The same with snake_case and true_property
@unittest.skipIf(is_pypy, "feature switching is not yet possible in PyPy")
def testCallConstructor_prop_snake(self):
- from __feature__ import snake_case, true_property
+ from __feature__ import snake_case, true_property # noqa: F401
label = QLabel(
- frame_style=QFrame.Panel | QFrame.Sunken, # QFrame attr, no property
+ frame_style=QFrame.Shape.Panel | QFrame.Shadow.Sunken, # QFrame attr, no property
line_width=2, # QFrame property
text="first line\nsecond line", # QLabel property
- alignment=Qt.AlignBottom | Qt.AlignRight # QLabel property
+ alignment=Qt.AlignmentFlag.AlignBottom | Qt.AlignmentFlag.AlignRight # QLabel property
)
self.assertEqual(label.line_width, 2)
self.assertRaises(AttributeError, lambda: QLabel(
diff --git a/sources/pyside6/tests/pysidetest/delegatecreateseditor_test.py b/sources/pyside6/tests/pysidetest/delegatecreateseditor_test.py
index ea39560bf..082885acb 100644
--- a/sources/pyside6/tests/pysidetest/delegatecreateseditor_test.py
+++ b/sources/pyside6/tests/pysidetest/delegatecreateseditor_test.py
@@ -50,7 +50,7 @@ class EditorCreatedByDelegateTest(UsesQApplication):
editor = view.getEditorWidgetFromItemDelegate()
self.assertEqual(type(editor), QComboBox)
self.assertEqual(editor.count(), 1)
- self.assertEqual(editor.itemData(0, Qt.DisplayRole), id_text)
+ self.assertEqual(editor.itemData(0, Qt.ItemDataRole.DisplayRole), id_text)
editor.metaObject()
def testDelegateKeepsReferenceToEditor(self):
@@ -60,7 +60,7 @@ class EditorCreatedByDelegateTest(UsesQApplication):
editor = view.getEditorWidgetFromItemDelegate()
self.assertEqual(type(editor), QComboBox)
self.assertEqual(editor.count(), 1)
- self.assertEqual(editor.itemData(0, Qt.DisplayRole), id_text)
+ self.assertEqual(editor.itemData(0, Qt.ItemDataRole.DisplayRole), id_text)
editor.metaObject()
def testIntDelegate(self):
@@ -68,7 +68,7 @@ class EditorCreatedByDelegateTest(UsesQApplication):
for anything that fits into a int. Verify by checking that a spin
box is created as item view editor for int."""
item = QStandardItem()
- item.setData(123123, Qt.EditRole) # <-- QVariant conversion here
+ item.setData(123123, Qt.ItemDataRole.EditRole) # <-- QVariant conversion here
model = QStandardItemModel()
model.appendRow(item)
style_option = QStyleOptionViewItem()
diff --git a/sources/pyside6/tests/pysidetest/enum_test.py b/sources/pyside6/tests/pysidetest/enum_test.py
index b36e77152..cfbe3ac72 100644
--- a/sources/pyside6/tests/pysidetest/enum_test.py
+++ b/sources/pyside6/tests/pysidetest/enum_test.py
@@ -26,8 +26,8 @@ class ListConnectionTest(unittest.TestCase):
self.assertEqual(TestObjectWithoutNamespace.Enum2.Option4, 4)
def testFlagComparisonOperators(self): # PYSIDE-1696, compare to self
- f1 = Qt.AlignHCenter | Qt.AlignBottom
- f2 = Qt.AlignHCenter | Qt.AlignBottom
+ f1 = Qt.AlignmentFlag.AlignHCenter | Qt.AlignmentFlag.AlignBottom
+ f2 = Qt.AlignmentFlag.AlignHCenter | Qt.AlignmentFlag.AlignBottom
self.assertTrue(f1 == f1)
self.assertTrue(f1 <= f1)
self.assertTrue(f1 >= f1)
@@ -42,10 +42,10 @@ class ListConnectionTest(unittest.TestCase):
self.assertFalse(f1 < f2)
self.assertFalse(f1 > f2)
- self.assertTrue(Qt.AlignHCenter < Qt.AlignBottom)
- self.assertFalse(Qt.AlignHCenter > Qt.AlignBottom)
- self.assertFalse(Qt.AlignBottom < Qt.AlignHCenter)
- self.assertTrue(Qt.AlignBottom > Qt.AlignHCenter)
+ self.assertTrue(Qt.AlignmentFlag.AlignHCenter < Qt.AlignmentFlag.AlignBottom)
+ self.assertFalse(Qt.AlignmentFlag.AlignHCenter > Qt.AlignmentFlag.AlignBottom)
+ self.assertFalse(Qt.AlignmentFlag.AlignBottom < Qt.AlignmentFlag.AlignHCenter)
+ self.assertTrue(Qt.AlignmentFlag.AlignBottom > Qt.AlignmentFlag.AlignHCenter)
# PYSIDE-1735: We are testing that opcodes do what they are supposed to do.
diff --git a/sources/pyside6/tests/pysidetest/new_inherited_functions_test.py b/sources/pyside6/tests/pysidetest/new_inherited_functions_test.py
index 10ac2c373..722adc5cb 100644
--- a/sources/pyside6/tests/pysidetest/new_inherited_functions_test.py
+++ b/sources/pyside6/tests/pysidetest/new_inherited_functions_test.py
@@ -31,7 +31,8 @@ new_functions = """
PySide6.QtCore.QAbstractListModel().parent()
PySide6.QtCore.QAbstractTableModel().parent()
PySide6.QtCore.QFile().resize(qint64)
- m = PySide6.QtCore.QMutex(); m.tryLock(); m.unlock() # prevent a message "QMutex: destroying locked mutex"
+ # prevent a message "QMutex: destroying locked mutex"
+ m = PySide6.QtCore.QMutex(); m.tryLock(); m.unlock()
PySide6.QtCore.QSortFilterProxyModel().parent()
PySide6.QtCore.QTemporaryFile(tfarg).open(openMode)
"""
@@ -58,7 +59,8 @@ new_functions += """
PySide6.QtWidgets.QGestureEvent([]).ignore()
PySide6.QtWidgets.QGestureEvent([]).isAccepted()
PySide6.QtWidgets.QGestureEvent([]).setAccepted(_bool)
- # PySide6.QtWidgets.QGraphicsView().render(qPaintDevice,qPoint,qRegion,renderFlags) # QPaintDevice: NotImplementedError
+ # QPaintDevice: NotImplementedError
+ # PySide6.QtWidgets.QGraphicsView().render(qPaintDevice,qPoint,qRegion,renderFlags)
PySide6.QtWidgets.QGridLayout().addWidget(qWidget)
PySide6.QtWidgets.QInputDialog().open()
PySide6.QtWidgets.QLineEdit().addAction(qAction)
@@ -75,13 +77,16 @@ new_functions += """
# PySide6.QtPrintSupport.QPageSetupDialog().open() # Segmentation fault: 11
# PySide6.QtPrintSupport.QPrintDialog().open() # opens the dialog, but works
PySide6.QtPrintSupport.QPrintDialog().printer()
- PySide6.QtPrintSupport.QPrintPreviewDialog().open() # note: this prints something, but really shouldn't ;-)
+ # note: this prints something, but really shouldn't ;-)
+ PySide6.QtPrintSupport.QPrintPreviewDialog().open()
""" if "PySide6.QtPrintSupport" in sys.modules else ""
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
+ # returns NULL without setting an error
+ # PySide6.QtHelp.QHelpIndexModel().createIndex(_int,_int,quintptr)
+ # returns NULL without setting an error
+ # PySide6.QtHelp.QHelpIndexModel().createIndex(_int,_int,object())
""" if "PySide6.QtHelp" in sys.modules else ""
new_functions += """
@@ -107,7 +112,7 @@ class MainTest(unittest.TestCase):
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
+ openMode = PySide6.QtCore.QIODevice.OpenMode(PySide6.QtCore.QIODevice.OpenModeFlag.ReadOnly) # noqa: F841,F405,E501
qModelIndex = PySide6.QtCore.QModelIndex() # noqa: F841,F405
transformationMode = PySide6.QtCore.Qt.TransformationMode() # noqa: F841,F405
qObject = PySide6.QtCore.QObject() # noqa: F841,F405
@@ -152,7 +157,7 @@ class MainTest(unittest.TestCase):
"""
try:
qApp = ( # noqa: F841
- PySide6.QtWidgets.QApplication.instance() or PySide6.QtWidgets.QApplication([]) # noqa: F405
+ PySide6.QtWidgets.QApplication.instance() or PySide6.QtWidgets.QApplication([]) # noqa: F405,E501
)
except AttributeError:
unittest.TestCase().skipTest("this test makes only sense if QtWidgets is available.")
diff --git a/sources/pyside6/tests/pysidetest/qvariant_test.py b/sources/pyside6/tests/pysidetest/qvariant_test.py
index 5748daee4..83b25b978 100644
--- a/sources/pyside6/tests/pysidetest/qvariant_test.py
+++ b/sources/pyside6/tests/pysidetest/qvariant_test.py
@@ -35,15 +35,16 @@ class QVariantTest(UsesQApplication):
def testQKeySequenceQVariantOperator(self):
# bug #775
- ks = QKeySequence(Qt.ShiftModifier, Qt.ControlModifier, Qt.Key_P, Qt.Key_R)
+ ks = QKeySequence(Qt.KeyboardModifier.ShiftModifier, Qt.KeyboardModifier.ControlModifier,
+ Qt.Key.Key_P, Qt.Key.Key_R)
self.assertEqual(TestObject.checkType(ks), 4107)
def testQKeySequenceMoreVariations(self):
- QAction().setShortcut(Qt.CTRL | Qt.Key_B)
- QAction().setShortcut(Qt.CTRL | Qt.ALT | Qt.Key_B)
- QAction().setShortcut(Qt.CTRL | Qt.AltModifier | Qt.Key_B)
- QAction().setShortcut(QKeySequence(QKeyCombination(Qt.CTRL | Qt.Key_B)))
- QKeySequence(Qt.CTRL | Qt.Key_Q)
+ QAction().setShortcut(Qt.Modifier.CTRL | Qt.Key.Key_B)
+ QAction().setShortcut(Qt.Modifier.CTRL | Qt.Modifier.ALT | Qt.Key.Key_B)
+ QAction().setShortcut(Qt.Modifier.CTRL | Qt.KeyboardModifier.AltModifier | Qt.Key.Key_B)
+ QAction().setShortcut(QKeySequence(QKeyCombination(Qt.Modifier.CTRL | Qt.Key.Key_B)))
+ QKeySequence(Qt.Modifier.CTRL | Qt.Key.Key_Q)
def testEnum(self):
# Testing C++ class
diff --git a/sources/pyside6/tests/signals/pysignal_test.py b/sources/pyside6/tests/signals/pysignal_test.py
index 9517b2fbc..c6e23e835 100644
--- a/sources/pyside6/tests/signals/pysignal_test.py
+++ b/sources/pyside6/tests/signals/pysignal_test.py
@@ -73,7 +73,7 @@ class PyObjectType(UsesQApplication):
self.called = False
self.running = True
o = Sender()
- o.dummy2.connect(self.mySlot2, Qt.QueuedConnection)
+ o.dummy2.connect(self.mySlot2, Qt.ConnectionType.QueuedConnection)
o.callDummy2()
self.app.exec()
self.assertEqual(self.callCount, 1)
@@ -82,7 +82,7 @@ class PyObjectType(UsesQApplication):
self.called = False
self.running = True
o = Sender()
- o.dummy2.connect(self.mySlot2, Qt.QueuedConnection)
+ o.dummy2.connect(self.mySlot2, Qt.ConnectionType.QueuedConnection)
o.callDummy2()
o.callDummy2()
self.app.exec()
diff --git a/sources/pyside6/tests/signals/signal_connectiontype_support_test.py b/sources/pyside6/tests/signals/signal_connectiontype_support_test.py
index bab0b9717..296185cce 100644
--- a/sources/pyside6/tests/signals/signal_connectiontype_support_test.py
+++ b/sources/pyside6/tests/signals/signal_connectiontype_support_test.py
@@ -32,7 +32,7 @@ class TestConnectionTypeSupport(unittest.TestCase):
"""Connect signal using a Qt.ConnectionType as argument"""
obj1 = Sender()
- obj1.foo.connect(self.callback, Qt.DirectConnection)
+ obj1.foo.connect(self.callback, Qt.ConnectionType.DirectConnection)
self.args = tuple()
obj1.foo.emit(*self.args)
diff --git a/sources/pyside6/tests/signals/signal_emission_test.py b/sources/pyside6/tests/signals/signal_emission_test.py
index b0c02b084..c4c6ac256 100644
--- a/sources/pyside6/tests/signals/signal_emission_test.py
+++ b/sources/pyside6/tests/signals/signal_emission_test.py
@@ -70,10 +70,10 @@ class PythonSignalToCppSlots(UsesQApplication):
sender.dummy.emit()
new_dir = timeline.direction()
- if orig_dir == QTimeLine.Forward:
- self.assertEqual(new_dir, QTimeLine.Backward)
+ if orig_dir == QTimeLine.Direction.Forward:
+ self.assertEqual(new_dir, QTimeLine.Direction.Backward)
else:
- self.assertEqual(new_dir, QTimeLine.Forward)
+ self.assertEqual(new_dir, QTimeLine.Direction.Forward)
def testWithArgs(self):
'''Connect python signals to QTimeLine.setCurrentTime(int)'''
@@ -117,10 +117,10 @@ class CppSignalsToCppSlots(UsesQApplication):
new_dir = timeline.direction()
- if orig_dir == QTimeLine.Forward:
- self.assertEqual(new_dir, QTimeLine.Backward)
+ if orig_dir == QTimeLine.Direction.Forward:
+ self.assertEqual(new_dir, QTimeLine.Direction.Backward)
else:
- self.assertEqual(new_dir, QTimeLine.Forward)
+ self.assertEqual(new_dir, QTimeLine.Direction.Forward)
called = False
@@ -159,8 +159,8 @@ class EmitEnum(UsesQApplication):
self.arg = None
p = QProcess()
p.stateChanged.connect(self.slot)
- p.stateChanged.emit(QProcess.NotRunning)
- self.assertEqual(self.arg, QProcess.NotRunning)
+ p.stateChanged.emit(QProcess.ProcessState.NotRunning)
+ self.assertEqual(self.arg, QProcess.ProcessState.NotRunning)
if __name__ == '__main__':
diff --git a/sources/pyside6/tests/signals/signal_newenum_test.py b/sources/pyside6/tests/signals/signal_newenum_test.py
index 64d171037..0140c7db7 100644
--- a/sources/pyside6/tests/signals/signal_newenum_test.py
+++ b/sources/pyside6/tests/signals/signal_newenum_test.py
@@ -32,7 +32,7 @@ class Sender(QObject):
super().__init__()
def emit_test_sig(self):
- self.test_sig.emit(Qt.AlignLeft, "bla")
+ self.test_sig.emit(Qt.AlignmentFlag.AlignLeft, "bla")
class TestSignalNewEnum(unittest.TestCase):
diff --git a/sources/pyside6/tests/signals/signal_object_test.py b/sources/pyside6/tests/signals/signal_object_test.py
index 84f2aba4c..777a4d0b0 100644
--- a/sources/pyside6/tests/signals/signal_object_test.py
+++ b/sources/pyside6/tests/signals/signal_object_test.py
@@ -75,7 +75,7 @@ class SignalObjectTest(UsesQApplication):
def testConnectionType(self):
o = MyObject()
- o.timeout.connect(self.cb, type=Qt.DirectConnection)
+ o.timeout.connect(self.cb, type=Qt.ConnectionType.DirectConnection)
o.start(100)
self.app.exec()
self.assertTrue(self._cb_called)