aboutsummaryrefslogtreecommitdiffstats
path: root/sources/pyside6/tests
diff options
context:
space:
mode:
authorShyamnath Premnadh <Shyamnath.Premnadh@qt.io>2023-02-23 09:09:50 +0100
committerShyamnath Premnadh <Shyamnath.Premnadh@qt.io>2023-02-27 14:39:19 +0100
commit5fac301e8e5a8d15eaff91d78b5deeeb2204c7b4 (patch)
tree29a1b8c7ff7ae1c25f9d0661f47f06811c77660b /sources/pyside6/tests
parent78b924368cc4c82a0cb6b0837f00dcf097d24223 (diff)
PySide: Add QRunnable create()
Fixes: PYSIDE-2234 Change-Id: I3fc1c669c3985a8aad57785927fb4e48e69431a4 Reviewed-by: Friedemann Kleint <Friedemann.Kleint@qt.io>
Diffstat (limited to 'sources/pyside6/tests')
-rw-r--r--sources/pyside6/tests/QtCore/CMakeLists.txt1
-rw-r--r--sources/pyside6/tests/QtCore/qrunnable_test.py45
2 files changed, 46 insertions, 0 deletions
diff --git a/sources/pyside6/tests/QtCore/CMakeLists.txt b/sources/pyside6/tests/QtCore/CMakeLists.txt
index 962011fb9..f584bfde6 100644
--- a/sources/pyside6/tests/QtCore/CMakeLists.txt
+++ b/sources/pyside6/tests/QtCore/CMakeLists.txt
@@ -140,6 +140,7 @@ PYSIDE_TEST(unaryoperator_test.py)
PYSIDE_TEST(unicode_test.py)
PYSIDE_TEST(versioninfo_test.py)
PYSIDE_TEST(loggingcategorymacros_test.py)
+PYSIDE_TEST(qrunnable_test.py)
if(X11)
PYSIDE_TEST(qhandle_test.py)
diff --git a/sources/pyside6/tests/QtCore/qrunnable_test.py b/sources/pyside6/tests/QtCore/qrunnable_test.py
new file mode 100644
index 000000000..0470a6cd2
--- /dev/null
+++ b/sources/pyside6/tests/QtCore/qrunnable_test.py
@@ -0,0 +1,45 @@
+# Copyright (C) 2023 The Qt Company Ltd.
+# SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0
+
+'''Test cases for QRunnable'''
+
+import os
+import sys
+import unittest
+from io import StringIO
+
+from pathlib import Path
+sys.path.append(os.fspath(Path(__file__).resolve().parents[1]))
+from init_paths import init_test_paths
+init_test_paths(False)
+
+from PySide6.QtCore import QCoreApplication, QRunnable, QThreadPool, QThread, qDebug
+from helper.usesqcoreapplication import UsesQCoreApplication
+test_result = ""
+
+
+def check_test():
+ global test_result
+ test_result = "test works"
+
+
+class QRunnableTest(UsesQCoreApplication):
+ def testCreateWithAutoDelete(self):
+ global test_result
+ test_result = "" # reset
+ runnable = QRunnable.create(check_test)
+ runnable.run()
+ self.assertEqual(test_result, "test works")
+
+ def testwithQThreadPool(self):
+ global test_result
+ test_result = "" # reset
+ runnable = QRunnable.create(check_test)
+ tp = QThreadPool.globalInstance()
+ tp.start(runnable)
+ self.assertTrue(tp.waitForDone())
+ self.assertEqual(test_result, "test works")
+
+
+if __name__ == '__main__':
+ unittest.main()